﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SystemModule;

namespace M2Server
{
    public partial class TPlayObject : TAnimalObject
    {
        public bool ClientPickUpItem_IsSelf(TBaseObject BaseObject)
        {
            bool result;
            if ((BaseObject == null) || (this == BaseObject))
            {
                result = true;
            }
            else
            {
                result = false;
            }
            return result;
        }

        public bool ClientPickUpItem_IsOfGroup(TBaseObject BaseObject)
        {
            bool result = false;
            TBaseObject GroupMember;
            if (m_GroupOwner == null)
            {
                return result;
            }
            for (int i = 0; i < m_GroupOwner.m_GroupMembers.Count; i++)
            {
                GroupMember = m_GroupOwner.m_GroupMembers[i];
                if (GroupMember == BaseObject)
                {
                    result = true;
                    break;
                }
            }
            return result;
        }

        /// <summary>
        /// 玩家捡起物品
        /// </summary>
        /// <returns></returns>
        private bool ClientPickUpItem()
        {
            bool result = false;
            TUserItem UserItem;
            TMapItem MapItem;
            TStdItem StdItem;
            TPlayObject PlayObject;
            if (m_boDealing)
            {
                return result;// 交易中则退出
            }
            if (this.m_boDeath)
            {
                return result; // 死亡则退出
            }
            MapItem = this.m_PEnvir.GetItem(this.m_nCurrX, this.m_nCurrY);
            if (MapItem == null)
            {
                return result;
            }
            if ((HUtil32.GetTickCount() - MapItem.dwCanPickUpTick) > M2Share.g_Config.dwFloorItemCanPickUpTime) // 2 * 60 * 1000
            {
                MapItem.OfBaseObject = null;
            }
            if (this.PlugOfCheckCanItem(9, MapItem.Name, false, 0, 0))  // 禁止物品规则(管理插件功能)
            {
                this.SysMsg(GameMsgDef.g_sPickUpItemHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);// 提示 禁止捡起
                return result;
            }
            if (!ClientPickUpItem_IsSelf(((MapItem.OfBaseObject) as TBaseObject)) && !ClientPickUpItem_IsOfGroup(((MapItem.OfBaseObject) as TBaseObject)))
            {
                // '在一定时间以内无法捡起此物品！！！'
                this.SysMsg(GameMsgDef.g_sCanotPickUpItem, TMsgColor.c_Red, TMsgType.t_Hint);
                return result;
            }
            if (string.Compare(MapItem.Name, M2Share.sSTRING_GOLDNAME, true) == 0) //如果是金币，直接增加到玩家身上
            {
                if (this.m_PEnvir.DeleteFromMap(this.m_nCurrX, this.m_nCurrY, Grobal2.OS_ITEMOBJECT, MapItem) == 1)
                {
                    if (IncGold(MapItem.Count))
                    {
                        this.SendRefMsg(Grobal2.RM_ITEMHIDE, 0, MapItem.ItemId, this.m_nCurrX, this.m_nCurrY, "");
                        if (M2Share.g_boGameLogGold)
                        {
                            M2Share.AddGameDataLog("4" + "\09" + this.m_sMapName + "\09" + this.m_nCurrX + "\09" + this.m_nCurrY + "\09" + this.m_sCharName + "\09"
                                + M2Share.sSTRING_GOLDNAME + "\09" + MapItem.Count + "\09" + "1" + "\09" + "0");
                        }
                        this.GoldChanged();
                        Dispose(MapItem);
                    }
                    else
                    {
                        this.m_PEnvir.AddToMap(this.m_nCurrX, this.m_nCurrY, Grobal2.OS_ITEMOBJECT, MapItem);
                    }
                }
                return result;
            }
            if (IsEnoughBag())
            {
                if (this.m_PEnvir.DeleteFromMap(this.m_nCurrX, this.m_nCurrY, Grobal2.OS_ITEMOBJECT, MapItem) == 1) //是否从地图删除物品
                {
                    UserItem = new TUserItem();//by John 修正
                    for (int i = 0; i < 22; i++)
                    {
                        UserItem.btValue[i] = 0;
                    }
                    UserItem = MapItem.UserItem;
                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                    if ((StdItem != null))
                    {
                        if (this.IsAddWeightAvailable(M2Share.UserEngine.GetStdItemWeight(UserItem.wIndex)))
                        {
                            this.SendMsg(this, Grobal2.RM_ITEMHIDE, 0, MapItem.ItemId, this.m_nCurrX, this.m_nCurrY, "");//从当前地图删除物品
                            ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理包裹和仓库复制物品
                            this.AddItemToBag(UserItem);
                            if (StdItem.NeedIdentify == 1)
                            {
                                M2Share.AddGameDataLog("4" + "\09" + this.m_sMapName + "\09" + this.m_nCurrX + "\09" +
                                    this.m_nCurrY + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09" + UserItem.MakeIndex +
                                    "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString()
                                    + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")"
                                    + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/"
                                    + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString()
                                    + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString() + "/"
                                    + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" +
                                    (UserItem.btValue[14]).ToString() + "\09" + (UserItem.Dura).ToString() + "/" + (UserItem.DuraMax).ToString());
                            }
                            Dispose(MapItem);
                            if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                            {
                                PlayObject = ((this) as TPlayObject);
                                PlayObject.SendAddItem(UserItem);
                            }
                            result = true;
                        }
                        else
                        {
                            UserItem = null;
                            this.m_PEnvir.AddToMap(this.m_nCurrX, this.m_nCurrY, Grobal2.OS_ITEMOBJECT, MapItem);
                        }
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// 运行游戏公告
        /// </summary>
        public void RunNotice()
        {
            TProcessMessage Msg = null;
            const string sExceptionMsg = "[异常] TPlayObject::RunNotice";
            if (m_boEmergencyClose || m_boKickFlag || m_boSoftClose)
            {
                if (m_boKickFlag)
                {
                    SendDefMessage(Grobal2.SM_OUTOFCONNECTION, 0, 0, 0, 0, "");//超过最大连接数
                }
                MakeGhost();
            }
            else
            {
                try
                {
                    if (!m_boSendNotice)
                    {
                        SendNotice();//发送游戏公告
                        m_boSendNotice = true;
                        m_dwWaitLoginNoticeOKTick = HUtil32.GetTickCount();
                    }
                    else
                    {
                        if (HUtil32.GetTickCount() - m_dwWaitLoginNoticeOKTick > 30000) // 30 * 1000
                        {
                            m_boEmergencyClose = true;//设置玩家标识掉线处理
                        }
                        while (this.GetMessage(ref Msg))
                        {
                            if (Msg.wIdent == Grobal2.CM_LOGINNOTICEOK)
                            {
                                m_boLoginNoticeOK = true;
                                m_dwClientTick = (uint)Msg.nParam1;
                                this.SysMsg(Convert.ToString(m_dwClientTick), TMsgColor.c_Red, TMsgType.t_Notice);
                            }
                        }
                        Msg = null;
                        Dispose(Msg);
                    }
                }
                catch
                {
                    M2Share.MainOutMessage(sExceptionMsg);
                }
            }
        }

        /// <summary>
        /// 发送聚灵珠使用剩余时间
        /// </summary>
        /// <param name="dwTime"></param>
        public void SendItemUseTime(int dwTime)
        {
            TUserItem UserItem;
            TStdItem AmuletStdItem;
            var boGetExpToItem = false;
            if (this.m_ItemList.Count > 0)
            {
                for (int i = 0; i < this.m_ItemList.Count; i++) // 人物包裹不为空
                {
                    UserItem = this.m_ItemList[i];
                    AmuletStdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                    if (AmuletStdItem != null)
                    {
                        if ((AmuletStdItem.StdMode == 51) && (AmuletStdItem.Shape == 0) && (UserItem.btValue[20] == 1)) // 聚灵珠
                        {
                            dwTime = dwTime / 3600;
                            this.SendMsg(this, Grobal2.RM_EXPTIMEITEMS, 0, UserItem.MakeIndex, dwTime, 0, "");// 发送聚灵珠剩于时间
                            boGetExpToItem = true;
                            break;
                        }
                    }
                }
            }
            if (!boGetExpToItem && (m_MyHero != null))
            {
                if (m_MyHero.m_ItemList.Count > 0)
                {
                    for (int i = 0; i < m_MyHero.m_ItemList.Count; i++)// 英雄包裹不为空
                    {
                        UserItem = m_MyHero.m_ItemList[i];
                        AmuletStdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                        if (AmuletStdItem != null)
                        {
                            if ((AmuletStdItem.StdMode == 51) && (AmuletStdItem.Shape == 0) && (UserItem.btValue[20] == 1))// 聚灵珠
                            {
                                dwTime = dwTime / 3600;
                                this.SendMsg(this, Grobal2.RM_EXPTIMEITEMS, 0, UserItem.MakeIndex, dwTime, 0, "");// 发送聚灵珠剩于时间
                                break;
                            }
                        }
                    }
                }
            }
        }

        /// <summary>
        /// 发送聚灵珠使用剩余时间 
        /// </summary>
        /// <param name="nCode">参数为1时,发送经验值,用于人物上线时发送</param>
        /// <returns></returns>
        public bool IsItem_51(int nCode)
        {
            bool result = false;
            TUserItem UserItem;
            TStdItem AmuletStdItem;
            try
            {
                var boGetExpToItem = false;
                if (this.m_ItemList.Count > 0)
                {
                    for (int i = 0; i < this.m_ItemList.Count; i++)// 人物包裹不为空
                    {
                        UserItem = this.m_ItemList[i];
                        if (UserItem != null)
                        {
                            AmuletStdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if (AmuletStdItem != null)
                            {
                                if ((AmuletStdItem.StdMode == 51) && (AmuletStdItem.Shape == 0) && (UserItem.btValue[12] != 2))
                                {
                                    switch (nCode)
                                    {
                                        case 1:// 聚灵珠
                                            if (UserItem.btValue[20] != 1)
                                            {
                                                continue;
                                            }
                                            if (this.m_nWinExp >= 10000)
                                            {
                                                UserItem.Dura++;
                                                this.m_nWinExp -= 10000;
                                                boGetExpToItem = true;
                                                if (UserItem.Dura > UserItem.DuraMax)
                                                {
                                                    UserItem.Dura = UserItem.DuraMax;
                                                }
                                            }
                                            this.SendMsg(this, Grobal2.RM_DURACHANGE, UserItem.wIndex, UserItem.Dura, UserItem.DuraMax, 0, "");
                                            SendItemUseTime(n_UsesItemTick);
                                            break;
                                        case 2:
                                            n_UsesItemTick = 0;// 时间初始
                                            UserItem.btValue[12] = 2; //增加,不能聚集的标识
                                            break;
                                    }
                                    result = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if ((nCode == 1) && !boGetExpToItem && (m_MyHero != null))
                {
                    if (m_MyHero.m_ItemList.Count > 0)
                    {
                        for (int i = 0; i < m_MyHero.m_ItemList.Count; i++)// 英雄包裹不为空
                        {
                            UserItem = m_MyHero.m_ItemList[i];
                            if (UserItem != null)
                            {
                                AmuletStdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if (AmuletStdItem != null)
                                {
                                    if ((AmuletStdItem.StdMode == 51) && (AmuletStdItem.Shape == 0) && (UserItem.btValue[12] != 2)) // 聚灵珠
                                    {
                                        if (UserItem.btValue[20] != 1)
                                        {
                                            continue;
                                        }
                                        if (this.m_nWinExp >= 10000)
                                        {
                                            UserItem.Dura++;
                                            this.m_nWinExp -= 10000;
                                            if (UserItem.Dura > UserItem.DuraMax)
                                            {
                                                UserItem.Dura = UserItem.DuraMax;
                                            }
                                        }
                                        ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HERODURACHANGE, UserItem.wIndex, UserItem.Dura, UserItem.DuraMax, 0, "");
                                        SendItemUseTime(n_UsesItemTick);
                                        ((THeroObject)(m_MyHero)).SendUpdateItem(UserItem);// 更新物品
                                        result = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.IsItem_51");
            }
            return result;
        }

        /// <summary>
        /// 发送装备到玩家包裹
        /// </summary>
        /// <param name="UserItem"></param>
        public unsafe virtual void SendAddItem(TUserItem UserItem)
        {
            TStdItem pStdItem;
            TStdItem StdItem;
            TClientItem ClientItem;
            TOClientItem* OClientItem = null;
            string sUserItemName;
            if (m_nSoftVersionDateEx == 0)
            {
                pStdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                if (pStdItem == null)
                {
                    return;
                }
                StdItem = pStdItem;
                M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem);
                M2Share.CopyStdItemToOStdItem(StdItem, &OClientItem->s);
                sUserItemName = "";   // 取自定义物品名称
                if (UserItem.btValue[13] == 1)
                {
                    sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                }
                if (sUserItemName != "")
                {
                    HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                }
                OClientItem->MakeIndex = UserItem.MakeIndex;
                OClientItem->Dura = UserItem.Dura;
                OClientItem->DuraMax = UserItem.DuraMax;
                if (new ArrayList(new int[] { 15, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem.StdMode))
                {
                    if (UserItem.btValue[8] == 0)
                    {
                        OClientItem->s.Shape = 0;
                    }
                    else
                    {
                        OClientItem->s.Shape = 130;
                    }
                }
                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_ADDITEM, this.m_ActorsId, 0, 0, 1, 0);
                SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(OClientItem, sizeof(TOClientItem)));
            }
            else
            {
                pStdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                if (pStdItem == null)
                {
                    return;
                }
                StdItem = pStdItem;
                M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem);
                ClientItem = new TClientItem
                {
                    s = StdItem
                };
                //Move(StdItem, ClientItem.s, sizeof(TStdItem));
                // 取自定义物品名称
                sUserItemName = "";
                if (UserItem.btValue[13] == 1)
                {
                    sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                }
                if (UserItem.btValue[12] == 1)// 物品发光
                {
                    ClientItem.s.Reserved1 = 1;
                }
                else
                {
                    ClientItem.s.Reserved1 = 0;
                }
                if (sUserItemName != "")
                {
                    ClientItem.s.Name = sUserItemName;
                    //HUtil32.StrToSByteArry(sUserItemName, ClientItem.s.Name, 14, ref ClientItem.s.NameLen);
                }
                ClientItem.MakeIndex = UserItem.MakeIndex;
                ClientItem.Dura = UserItem.Dura;
                ClientItem.DuraMax = UserItem.DuraMax;
                switch (StdItem.StdMode)
                {
                    case 8:
                        if (UserItem.btValue[0] != 0) // 材料的品质
                        {
                            ClientItem.s.AC = UserItem.btValue[0];
                        }
                        break;
                    case 15:
                    case 19:
                    case 20:
                    case 21:
                    case 22:
                    case 23:
                    case 24:
                    case 26:
                        if (UserItem.btValue[8] != 0)
                        {
                            ClientItem.s.Shape = 130;
                        }
                        break;
                    case 51:// 如果是聚灵珠,则换成小时数
                        if ((StdItem.Shape == 0))
                        {
                            ClientItem.s.Need = StdItem.AniCount * 24;
                        }
                        break;
                    case 60:// 酒类,除烧酒外
                        if ((StdItem.Shape != 0))
                        {
                            if (UserItem.btValue[0] != 0)
                            {
                                ClientItem.s.AC = UserItem.btValue[0]; // 酒的品质
                            }
                            if (UserItem.btValue[1] != 0)
                            {
                                ClientItem.s.MAC = UserItem.btValue[1]; // 酒的酒精度
                            }
                        }
                        break;
                }
                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_ADDITEM, this.m_ActorsId, 0, 0, 1, 0);
                SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer<TClientItem>(ClientItem));
            }
        }

        /// <summary>
        /// 是否组队成员
        /// </summary>
        /// <param name="Target"></param>
        /// <returns></returns>
        public bool IsGroupMember(TBaseObject Target)
        {
            bool result = false;
            try
            {
                if ((m_GroupOwner == null) || (Target == null) || (this == null))
                {
                    return result;
                }
                for (int i = 0; i < m_GroupOwner.m_GroupMembers.Count; i++)
                {
                    if (m_GroupOwner.m_GroupMembers[i] == Target)
                    {
                        result = true;
                        break;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.IsGroupMember");
            }
            return result;
        }

        /// <summary>
        /// 私聊
        /// </summary>
        /// <param name="whostr">对谁说的</param>
        /// <param name="saystr"></param>
        public void Whisper(string whostr, string saystr)
        {
            TPlayObject PlayObject = M2Share.UserEngine.GetPlayObject(whostr);
            int svidx = 0;
            if (PlayObject != null)
            {
                if (!PlayObject.m_boReadyRun)
                {
                    // '无法发送信息.'
                    this.SysMsg(whostr + GameMsgDef.g_sCanotSendmsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    return;
                }
                if (!PlayObject.m_boHearWhisper || PlayObject.IsBlockWhisper(this.m_sCharName))
                {
                    // ' 拒绝私聊！！！'
                    this.SysMsg(whostr + GameMsgDef.g_sUserDenyWhisperMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    return;
                }
                if (M2Share.g_Config.boRecordClientMsg && (saystr != ""))
                {
                    M2Share.MainOutMessage("[私聊] " + this.m_sCharName + "=>" + PlayObject.m_sCharName + ":" + saystr);// 记录私聊聊天信息
                }
                if ((PlayObject.m_boNotOnlineAddExp) && (PlayObject.m_sAutoSendMsg != ""))// 离线挂机人物自动回复
                {
                    if (this.m_btPermission >= 10)
                    {
                        this.SendMsg(this, Grobal2.RM_WHISPER, 0, M2Share.g_Config.btGMWhisperMsgFColor, M2Share.g_Config.btGMWhisperMsgBColor, 0, PlayObject.m_sCharName + "=>" + " " + PlayObject.m_sAutoSendMsg);
                    }
                    else
                    {
                        this.SendMsg(this, Grobal2.RM_WHISPER, 0, m_btWhisperMsgFColor, M2Share.g_Config.btWhisperMsgBColor, 0, PlayObject.m_sCharName + "=>" + " " + PlayObject.m_sAutoSendMsg);
                    }
                    return;
                }
                if (this.m_btPermission > 0)
                {
                    PlayObject.SendMsg(PlayObject, Grobal2.RM_WHISPER, 0, M2Share.g_Config.btGMWhisperMsgFColor, M2Share.g_Config.btGMWhisperMsgBColor, 0, this.m_sCharName + "=> " + saystr);
                    // 取得私聊信息
                    // m_GetWhisperHuman 侦听私聊对象
                    if ((m_GetWhisperHuman != null) && (!m_GetWhisperHuman.m_boGhost))
                    {
                        m_GetWhisperHuman.SendMsg(m_GetWhisperHuman, Grobal2.RM_WHISPER, 0, M2Share.g_Config.btGMWhisperMsgFColor, M2Share.g_Config.btGMWhisperMsgBColor, 0, this.m_sCharName + "=>" + PlayObject.m_sCharName + " " + saystr);
                    }
                    if ((PlayObject.m_GetWhisperHuman != null) && (!PlayObject.m_GetWhisperHuman.m_boGhost))
                    {
                        PlayObject.m_GetWhisperHuman.SendMsg(PlayObject.m_GetWhisperHuman, Grobal2.RM_WHISPER, 0, M2Share.g_Config.btGMWhisperMsgFColor, M2Share.g_Config.btGMWhisperMsgBColor, 0, this.m_sCharName + "=>" + PlayObject.m_sCharName + " " + saystr);
                    }
                }
                else
                {
                    PlayObject.SendMsg(PlayObject, Grobal2.RM_WHISPER, 0, m_btWhisperMsgFColor, M2Share.g_Config.btWhisperMsgBColor, 0, this.m_sCharName + "=> " + saystr);
                    if ((m_GetWhisperHuman != null) && (!m_GetWhisperHuman.m_boGhost))
                    {
                        m_GetWhisperHuman.SendMsg(m_GetWhisperHuman, Grobal2.RM_WHISPER, 0, m_btWhisperMsgFColor, M2Share.g_Config.btWhisperMsgBColor, 0, this.m_sCharName + "=>" + PlayObject.m_sCharName + " " + saystr);
                    }
                    if ((PlayObject.m_GetWhisperHuman != null) && (!PlayObject.m_GetWhisperHuman.m_boGhost))
                    {
                        PlayObject.m_GetWhisperHuman.SendMsg(PlayObject.m_GetWhisperHuman, Grobal2.RM_WHISPER, 0, m_btWhisperMsgFColor, M2Share.g_Config.btWhisperMsgBColor, 0, this.m_sCharName + "=>" + PlayObject.m_sCharName + " " + saystr);
                    }
                }
            }
            else
            {
                if (M2Share.UserEngine.FindOtherServerUser(whostr, ref svidx)) //查找其他服务器角色
                {
                    M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_WHISPER, svidx, whostr + "/" + this.m_sCharName + "=> " + saystr);
                }
                else
                {
                    // '  没有在线！！！'
                    this.SysMsg(whostr + GameMsgDef.g_sUserNotOnLine, TMsgColor.c_Red, TMsgType.t_Hint);
                }
            }
        }

        /// <summary>
        /// 私聊
        /// </summary>
        /// <returns></returns>
        public bool IsBlockWhisper(string sName)
        {
            bool result = false;
            for (int i = 0; i < m_BlockWhisperList.Count; i++)
            {
                if ((sName).ToLower().CompareTo((m_BlockWhisperList[i]).ToLower()) == 0)
                {
                    result = true;
                    break;
                }
            }
            return result;
        }

        /// <summary>
        /// 刷新玩家状态
        /// </summary>
        public void RefUserState()
        {
            int n8 = 0;
            if (this.m_PEnvir.m_boFightZone || this.m_PEnvir.m_boFight2Zone)
            {
                n8 = n8 | 1;
            }
            if (this.m_PEnvir.m_boSAFE)
            {
                n8 = n8 | 2;
            }
            if (this.m_boInFreePKArea)
            {
                n8 = n8 | 4;
            }
            SendDefMessage(Grobal2.SM_AREASTATE, n8, 0, 0, 0, "");
        }

        public void RefMyStatus()
        {
            RecalcAbilitys();
            this.CompareSuitItem(false);// 套装
            this.SendMsg(this, Grobal2.RM_MYSTATUS, 0, 0, 0, 0, "");
        }

        /// <summary>
        /// 祈祷属性装备
        /// </summary>
        private void ProcessSpiritSuite()
        {
            TStdItem StdItem;
            TUserItem UseItem;
            if (!M2Share.g_Config.boSpiritMutiny || !this.m_bopirit)
            {
                return;
            }
            this.m_bopirit = false;
            for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
            {
                UseItem = this.m_UseItems[i];
                if (UseItem == null) { continue; }
                if (UseItem.wIndex <= 0)
                {
                    continue;
                }
                StdItem = M2Share.UserEngine.GetStdItem(UseItem.wIndex);
                if (StdItem != null)
                {
                    if ((StdItem.Shape == 126) || (StdItem.Shape == 127) || (StdItem.Shape == 128) || (StdItem.Shape == 129))
                    {
                        SendDelItems(UseItem);
                        UseItem.wIndex = 0;
                    }
                }
            }
            RecalcAbilitys();
            this.CompareSuitItem(false); //套装
            M2Share.g_dwSpiritMutinyTick = HUtil32.GetTickCount() + M2Share.g_Config.dwSpiritMutinyTime;
            M2Share.UserEngine.SendBroadCastMsg("神之祈祷，天地震怒，尸横遍野...", TMsgType.t_System);
            this.SysMsg("祈祷发出强烈的宇宙效应", TMsgColor.c_Green, TMsgType.t_Hint);
        }

        private void LogonTimcCost()
        {
            uint n08;
            string SC = string.Empty;
            if ((m_nPayMent == 2) || (M2Share.g_Config.boTestServer))
            {
                n08 = HUtil32.GetTickCount() - m_dwLogonTick / 1000;
            }
            else
            {
                n08 = 0;
            }
            //SC = m_sIPaddr + "\09" + m_sUserID + "\09" + this.m_sCharName + "\09" + (n08).ToString() + "\09" + FormatDateTime("yyyy-mm-dd hh:mm:ss", m_dLogonTime) + "\09" + FormatDateTime("yyyy-mm-dd hh:mm:ss", DateTime.Now) + "\09" + (m_nPayMode).ToString();
            M2Share.AddLogonCostLog(SC);
            if (m_nPayMode == 2)
            {
                //IdSrvClient.Units.IdSrvClient.FrmIDSoc.SendLogonCostMsg(m_sUserID, n08 / 60);
            }
        }

        /// <summary>
        /// 取下属数量
        /// </summary>
        /// <returns></returns>
        public int MakeSelf_GetSlaveCount()
        {
            return this.m_SlaveList.FindAll(delegate (TBaseObject BaseObject)
            {
                return BaseObject.m_nCopyHumanLevel == 2;
            }).Count();

            //int result = 0;
            //TBaseObject BaseObject;
            //if (this.m_SlaveList.Count <= 0)
            //{
            //    return result;
            //}
            //for (int i = 0; i < this.m_SlaveList.Count; i++)
            //{
            //    BaseObject = this.m_SlaveList[i];
            //    if (BaseObject.m_nCopyHumanLevel == 2)
            //    {
            //        result++;
            //    }
            //}
            //return result;
        }

        public bool MakeSelf_GetPosition1(ref int nX, ref int nY, byte nDir)
        {
            bool result;
            var Envir = this.m_PEnvir;
            nX = this.m_nCurrX;
            nY = this.m_nCurrY;
            switch (nDir)
            {
                case Grobal2.DR_UP:// 北
                    if (nY > 0)
                    {
                        nY -= 3;
                    }
                    break;
                case Grobal2.DR_UPRIGHT:// 东北向
                    if ((nX < (Envir.m_nWidth - 1)) && (nY > 0))
                    {
                        nX += 3;
                        nY -= 3;
                    }
                    break;
                case Grobal2.DR_RIGHT:// 东
                    if (nX < (Envir.m_nWidth - 1))
                    {
                        nX += 3;
                    }
                    break;
                case Grobal2.DR_DOWNRIGHT:// 东南向
                    if ((nX < (Envir.m_nWidth - 1)) && (nY < (Envir.m_nHeight - 1)))
                    {
                        nX += 3;
                        nY += 3;
                    }
                    break;
                case Grobal2.DR_DOWN:// 正南
                    if (nY < (Envir.m_nHeight - 1))
                    {
                        nY += 3;
                    }
                    break;
                case Grobal2.DR_DOWNLEFT:// 西南向
                    if ((nX > 0) && (nY < (Envir.m_nHeight - 1)))
                    {
                        nX -= 3;
                        nY += 3;
                    }
                    break;
                case Grobal2.DR_LEFT:// 西
                    if (nX > 0)
                    {
                        nX -= 3;
                    }
                    break;
                case Grobal2.DR_UPLEFT:// 西北向
                    if ((nX > 0) && (nY > 0))
                    {
                        nX -= 3;
                        nY -= 3;
                    }
                    break;
            }
            result = true;
            return result;
        }

        /// <summary>
        /// 创建分身
        /// </summary>
        /// <returns></returns>
        public TBaseObject MakeSelf(TPlayObject PlayObject, string sMonName, int nMaxMob, uint dwRoyaltySec)
        {
            TBaseObject result = null;
            int nX = 0;
            int nY = 0;
            TBaseObject MonObj;
            if (MakeSelf_GetSlaveCount() < nMaxMob)
            {
                MakeSelf_GetPosition1(ref nX, ref nY, PlayObject.m_btDirection);  // 分身效果需在主人3格外显示
                MonObj = M2Share.UserEngine.RegenPlayByName(PlayObject, nX, nY, sMonName);
                if (MonObj != null)
                {
                    MonObj.m_Master = this;
                    MonObj.m_dwMasterRoyaltyTick = dwRoyaltySec * 1000;
                    MonObj.m_dwMasterRoyaltyTime = HUtil32.GetTickCount();
                    MonObj.m_btSlaveMakeLevel = (byte)this.m_Abil.Level;
                    MonObj.m_btSlaveExpLevel = (byte)this.m_Abil.MaxExp;
                    MonObj.m_btNameColor = M2Share.g_Config.nCopyHumNameColor;// 分身名字颜色
                    MonObj.RecalcAbilitys();
                    if (MonObj.m_WAbil.HP < MonObj.m_WAbil.MaxHP)
                    {
                        MonObj.m_WAbil.HP = MonObj.m_WAbil.HP + (MonObj.m_WAbil.MaxHP - MonObj.m_WAbil.HP) / 2;
                    }
                    if (PlayObject.m_boPKFlag)
                    {
                        MonObj.m_dwPKTick = PlayObject.m_dwPKTick;
                        MonObj.m_boPKFlag = PlayObject.m_boPKFlag;
                    }
                    if (MonObj.m_btRaceServer == Grobal2.RC_PLAYMOSTER)
                    {
                        ((TPlayMonster)(MonObj)).m_boProtectStatus = false; // 分身没有守护模式
                    }
                    MonObj.RefNameColor();
                    this.m_SlaveList.Add(MonObj);
                    result = MonObj;
                }
            }
            return result;
        }

        /// <summary>
        /// 命令处理部分
        /// </summary>
        /// <param name="sData"></param>
        public void ProcessUserLineMsg(string sData)
        {
            string SC;
            string sCmd = string.Empty;
            string sParam1 = string.Empty;
            string sParam2 = string.Empty;
            string sParam3 = string.Empty;
            string sParam4 = string.Empty;
            string sParam5 = string.Empty;
            string sParam6 = string.Empty;
            string sParam7 = string.Empty;
            int nFlag;
            int nValue;
            int nLen;
            const string sExceptionMsg = "[异常] TPlayObject::ProcessUserLineMsg Msg = {0}";
            try
            {
                if (m_boSoftClose)
                {
                    return;
                }
                nLen = sData.Length;
                if (m_boSetStoragePwd)
                {
                    m_boSetStoragePwd = false;
                    if ((nLen > 3) && (nLen < 8))
                    {
                        m_sTempPwd = sData;
                        m_boReConfigPwd = true;
                        this.SysMsg(GameMsgDef.g_sReSetPasswordMsg, TMsgColor.c_Green, TMsgType.t_Hint);//请重复输入一次仓库密码：'
                        this.SendMsg(this, Grobal2.RM_PASSWORD, 0, 0, 0, 0, "");
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sPasswordOverLongMsg, TMsgColor.c_Red, TMsgType.t_Hint);//'输入的密码长度不正确！！！，密码长度必须在 4 - 7 的范围内，请重新设置密码。'
                    }
                    return;
                }
                if (m_boReConfigPwd)
                {
                    m_boReConfigPwd = false;
                    if (m_sTempPwd.CompareTo(sData) == 0)
                    {
                        m_sStoragePwd = sData;
                        m_boPasswordLocked = true;
                        m_boCanGetBackItem = false;
                        m_sTempPwd = "";
                        this.SysMsg(GameMsgDef.g_sReSetPasswordOKMsg, TMsgColor.c_Blue, TMsgType.t_Hint);// '密码设置成功！！，仓库已经自动上锁，请记好您的仓库密码，在取仓库时需要使用此密码开锁。'
                    }
                    else
                    {
                        m_sTempPwd = "";
                        this.SysMsg(GameMsgDef.g_sReSetPasswordNotMatchMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    return;
                }
                if (m_boUnLockPwd || m_boUnLockStoragePwd)
                {
                    if (m_sStoragePwd.CompareTo(sData) == 0)
                    {
                        m_boPasswordLocked = false;
                        if (m_boUnLockPwd)
                        {
                            if (M2Share.g_Config.boLockDealAction)
                            {
                                m_boCanDeal = true;
                            }
                            if (M2Share.g_Config.boLockDropAction)
                            {
                                m_boCanDrop = true;
                            }
                            if (M2Share.g_Config.boLockWalkAction)
                            {
                                m_boCanWalk = true;
                            }
                            if (M2Share.g_Config.boLockRunAction)
                            {
                                m_boCanRun = true;
                            }
                            if (M2Share.g_Config.boLockHitAction)
                            {
                                m_boCanHit = true;
                            }
                            if (M2Share.g_Config.boLockSpellAction)
                            {
                                m_boCanSpell = true;
                            }
                            if (M2Share.g_Config.boLockCallHeroAction)
                            {
                                m_boCallHero = true;
                            }
                            if (M2Share.g_Config.boLockSendMsgAction)// 是否锁定召唤英雄操作
                            {
                                m_boCanSendMsg = true;
                            }
                            if (M2Share.g_Config.boLockUserItemAction)
                            {
                                m_boCanUseItem = true;
                            }
                            if (M2Share.g_Config.boLockInObModeAction)
                            {
                                this.m_boObMode = false;
                                this.m_boAdminMode = false;
                            }
                            m_boLockLogoned = true;
                            this.SysMsg(GameMsgDef.g_sPasswordUnLockOKMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                        }
                        if (m_boUnLockStoragePwd)
                        {
                            if (M2Share.g_Config.boLockGetBackItemAction)
                            {
                                m_boCanGetBackItem = true;
                            }
                            this.SysMsg(GameMsgDef.g_sStorageUnLockOKMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        m_btPwdFailCount++;
                        this.SysMsg(GameMsgDef.g_sUnLockPasswordFailMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                        if (m_btPwdFailCount > 3)
                        {
                            this.SysMsg(GameMsgDef.g_sStoragePasswordLockedMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    m_boUnLockPwd = false;
                    m_boUnLockStoragePwd = false;
                    return;
                }
                if (m_boCheckOldPwd)
                {
                    m_boCheckOldPwd = false;
                    if (m_sStoragePwd == sData)
                    {
                        this.SendMsg(this, Grobal2.RM_PASSWORD, 0, 0, 0, 0, "");
                        this.SysMsg(GameMsgDef.g_sSetPasswordMsg, TMsgColor.c_Green, TMsgType.t_Hint);
                        m_boSetStoragePwd = true;
                    }
                    else
                    {
                        m_btPwdFailCount++;
                        this.SysMsg(GameMsgDef.g_sOldPasswordIncorrectMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                        if (m_btPwdFailCount > 3)
                        {
                            this.SysMsg(GameMsgDef.g_sStoragePasswordLockedMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                            m_boPasswordLocked = true;
                        }
                    }
                    return;
                }
                if (!sData.StartsWith("@"))
                {
                    if (sData.Length > M2Share.g_Config.nSayMsgMaxLen)
                    {
                        sData = sData.Substring(0, M2Share.g_Config.nSayMsgMaxLen);
                    }
                    if (M2Share.IsFilterMsg(ref sData))
                    {
                        ProcessSayMsg(sData);  // 文字过滤
                    }
                    return;
                }
                else
                {
                    ProcessCommand(sCmd, sData);
                }
            }
            catch
            {
                M2Share.MainOutMessage(string.Format(sExceptionMsg, sData));
            }
        }

        private bool HorseRunTo(byte btDir, bool boFlag)
        {
            bool result = false;
            int n10;
            int n14;
            const string sExceptionMsg = "[异常] TPlayObject::HorseRunTo";
            try
            {
                n10 = this.m_nCurrX;
                n14 = this.m_nCurrY;
                this.m_btDirection = btDir;
                switch (btDir)
                {
                    case Grobal2.DR_UP:// 0
                        if ((this.m_nCurrY > 2) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX, this.m_nCurrY - 1, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX, this.m_nCurrY - 2, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX, this.m_nCurrY - 3, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, this.m_nCurrX, this.m_nCurrY - 3, true) > 0))
                        {
                            this.m_nCurrY -= 3;
                        }
                        break;
                    case Grobal2.DR_UPRIGHT:// 1
                        if ((this.m_nCurrX < this.m_PEnvir.m_nWidth - 3) && (this.m_nCurrY > 2) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 1, this.m_nCurrY - 1, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 2, this.m_nCurrY - 2, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 3, this.m_nCurrY - 3, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, this.m_nCurrX + 3, this.m_nCurrY - 3, true) > 0))
                        {
                            this.m_nCurrX += 3;
                            this.m_nCurrY -= 3;
                        }
                        break;
                    case Grobal2.DR_RIGHT:// 2
                        if ((this.m_nCurrX < this.m_PEnvir.m_nWidth - 3) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 1, this.m_nCurrY, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 2, this.m_nCurrY, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 3, this.m_nCurrY, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, this.m_nCurrX + 3, this.m_nCurrY, true) > 0))
                        {
                            this.m_nCurrX += 3;
                        }
                        break;
                    case Grobal2.DR_DOWNRIGHT:// 3
                        if ((this.m_nCurrX < this.m_PEnvir.m_nWidth - 3) && (this.m_nCurrY < this.m_PEnvir.m_nHeight - 3) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 1, this.m_nCurrY + 1, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 2, this.m_nCurrY + 2, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX + 3, this.m_nCurrY + 3, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, this.m_nCurrX + 3, this.m_nCurrY + 3, true) > 0))
                        {
                            this.m_nCurrX += 3;
                            this.m_nCurrY += 3;
                        }
                        break;
                    case Grobal2.DR_DOWN:// 4
                        if ((this.m_nCurrY < this.m_PEnvir.m_nHeight - 3) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX, this.m_nCurrY + 1, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX, this.m_nCurrY + 2, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX, this.m_nCurrY + 3, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, this.m_nCurrX, this.m_nCurrY + 3, true) > 0))
                        {
                            this.m_nCurrY += 3;
                        }
                        break;
                    case Grobal2.DR_DOWNLEFT:// 5
                        if ((this.m_nCurrX > 2) && (this.m_nCurrY < this.m_PEnvir.m_nHeight - 3) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 1, this.m_nCurrY + 1, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 2, this.m_nCurrY + 2, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 3, this.m_nCurrY + 3, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, this.m_nCurrX - 3, this.m_nCurrY + 3, true) > 0))
                        {
                            this.m_nCurrX -= 3;
                            this.m_nCurrY += 3;
                        }
                        break;
                    case Grobal2.DR_LEFT:// 6
                        if ((this.m_nCurrX > 2) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 1, this.m_nCurrY, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 2, this.m_nCurrY, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 3, this.m_nCurrY, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, this.m_nCurrX - 3, this.m_nCurrY, true) > 0))
                        {
                            this.m_nCurrX -= 3;
                        }
                        break;
                    case Grobal2.DR_UPLEFT:// 7
                        if ((this.m_nCurrX > 2) && (this.m_nCurrY > 2) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 1, this.m_nCurrY - 1, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 2, this.m_nCurrY - 2, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.CanWalkEx(this.m_nCurrX - 3, this.m_nCurrY - 3, M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll)) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone())) && (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, this.m_nCurrX - 3, this.m_nCurrY - 3, true) > 0))
                        {
                            this.m_nCurrX -= 3;
                            this.m_nCurrY -= 3;
                        }
                        break;
                }
                // SysMsg(format('原X:%d 原Y:%d 新X:%d 新Y:%d',[n10,n14,m_nCurrX,m_nCurrY]),c_Green,t_Hint);
                if ((this.m_nCurrX != n10) || (this.m_nCurrY != n14))
                {
                    if (this.Walk(Grobal2.RM_HORSERUN))
                    {
                        result = true;
                    }
                    else
                    {
                        this.m_nCurrX = n10;
                        this.m_nCurrY = n14;
                        this.m_PEnvir.MoveToMovingObject(n10, n14, this, this.m_nCurrX, this.m_nCurrX, true);
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg);
            }
            return result;
        }

        /// <summary>
        /// 取范围内玩家数量
        /// </summary>
        /// <returns></returns>
        private int GetRangeHumanCount()
        {
            return M2Share.UserEngine.GetMapOfRangeHumanCount(this.m_PEnvir, this.m_nCurrX, this.m_nCurrY, 10);
        }

        /// <summary>
        /// 取复活点
        /// </summary>
        private void GetStartPoint()
        {
            try
            {
                HUtil32.EnterCriticalSection(M2Share.g_StartPointList);
                if (this.PKLevel() >= 2) //红名玩家获取红名村地址配置
                {
                    this.m_sHomeMap = M2Share.g_Config.sRedHomeMap;
                    this.m_nHomeX = M2Share.g_Config.nRedHomeX;
                    this.m_nHomeY = M2Share.g_Config.nRedHomeY;
                }
                foreach (TStartPoint StartPoint in M2Share.g_StartPointList)
                {
                    if (StartPoint.m_sMapName == this.m_PEnvir.sMapName)
                    {
                        if (StartPoint != null)
                        {
                            if ((Math.Abs(this.m_nCurrX - StartPoint.m_nCurrX) < 50) && (Math.Abs(this.m_nCurrY - StartPoint.m_nCurrY) < 50))
                            {
                                this.m_sHomeMap = StartPoint.m_sMapName;
                                this.m_nHomeX = StartPoint.m_nCurrX;
                                this.m_nHomeY = StartPoint.m_nCurrY;
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.g_StartPointList);
            }
        }

        // 元宝寄售取消出售
        public void SellOffCancel()
        {
            this.SendMsg(this, Grobal2.RM_SELLOFFCANCEL, 0, 0, 0, 0, "");
            GetBackSellOffItems();
        }

        /// <summary>
        /// 交易取消
        /// </summary>
        public void DealCancel()
        {
            if (!m_boDealing)
            {
                return;
            }
            m_boDealing = false;
            SendDefMessage(Grobal2.SM_DEALCANCEL, 0, 0, 0, 0, "");
            if (m_DealCreat != null)
            {
                m_DealCreat.DealCancel();
            }
            m_DealCreat = null;
            GetBackDealItems();// '交易取消'
            this.SysMsg(GameMsgDef.g_sDealActionCancelMsg, TMsgColor.c_Green, TMsgType.t_Hint);
            m_DealLastTick = HUtil32.GetTickCount();
        }

        public void DealCancelA()
        {
            this.m_Abil.HP = this.m_WAbil.HP;
            DealCancel();
        }

        // PK死亡
        public void GameTimeChanged()
        {
            if (m_nBright != M2Share.g_nGameTime)
            {
                m_nBright = M2Share.g_nGameTime;
                this.SendMsg(this, Grobal2.RM_DAYCHANGING, 0, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 取备份元宝寄售列表物品
        /// </summary>
        public void GetBackSellOffItems()
        {
            TUserItem UserItem = null;
            if (m_SellOffItemList.Count > 0)
            {
                for (int i = m_SellOffItemList.Count - 1; i >= 0; i--)
                {
                    UserItem = new TUserItem();
                    UserItem = m_SellOffItemList[i];
                    this.m_ItemList.Add(UserItem);
                    m_SellOffItemList.RemoveAt(i);
                }
            }
            m_boSellOffOK = false;// 确认元宝寄售标志
        }

        public void GetBackDealItems()
        {
            if (m_DealItemList.Count > 0)
            {
                for (int i = 0; i < m_DealItemList.Count; i++)
                {
                    this.m_ItemList.Add(m_DealItemList[i]);
                }
            }
            m_DealItemList.Clear();
            this.m_nGold += m_nDealGolds;
            m_nDealGolds = 0;
            m_boDealOK = false;
        }

        /// <summary>
        /// 获取包裹使用物品
        /// </summary>
        public void GetBagUseItems(ref byte btDc, ref byte btSc, ref byte btMc, ref byte btDura)
        {
            ArrayList DuraList;
            TUserItem UserItem;
            TStdItem StdItem;
            TStdItem StdItem80;
            List<string> DelItemList;
            int nDc;
            int nSc;
            int nMc;
            int nDcMin;
            int nDcMax;
            int nScMin;
            int nScMax;
            int nMcMin;
            int nMcMax;
            int nDura;
            int nItemCount;
            nDcMin = 0;
            nDcMax = 0;
            nScMin = 0;
            nScMax = 0;
            nMcMin = 0;
            nMcMax = 0;
            nDura = 0;
            nItemCount = 0;
            DelItemList = null;
            DuraList = new ArrayList();
            for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
            {
                if (this.m_ItemList.Count <= 0)
                {
                    break;
                }
                UserItem = this.m_ItemList[i];
                if (UserItem == null)
                {
                    continue;
                }
                if (M2Share.UserEngine.GetStdItemName(UserItem.wIndex) == M2Share.g_Config.sBlackStone)
                {
                    DuraList.Add((HUtil32.Round(UserItem.Dura / 1.0E3) as object));
                    if (DelItemList == null)
                    {
                        DelItemList = new List<string>();
                    }
                    //DelItemList.Add(M2Share.g_Config.sBlackStone, ((UserItem.MakeIndex) as Object));
                    UserItem = null;
                    this.m_ItemList.RemoveAt(i);
                }
                else
                {
                    if (M2Share.IsUseItem(UserItem.wIndex))
                    {
                        StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                        if (StdItem != null)
                        {
                            StdItem80 = StdItem;
                            M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem80);
                            nDc = 0;
                            nSc = 0;
                            nMc = 0;
                            switch (StdItem80.StdMode)
                            {
                                case 19:
                                case 20:
                                case 21:
                                    nDc = HUtil32.HiWord(StdItem80.DC) + HUtil32.LoWord(StdItem80.DC);
                                    nSc = HUtil32.HiWord(StdItem80.SC) + HUtil32.LoWord(StdItem80.SC);
                                    nMc = HUtil32.HiWord(StdItem80.MC) + HUtil32.LoWord(StdItem80.MC);
                                    break;
                                case 22:
                                case 23:
                                    nDc = HUtil32.HiWord(StdItem80.DC) + HUtil32.LoWord(StdItem80.DC);
                                    nSc = HUtil32.HiWord(StdItem80.SC) + HUtil32.LoWord(StdItem80.SC);
                                    nMc = HUtil32.HiWord(StdItem80.MC) + HUtil32.LoWord(StdItem80.MC);
                                    break;
                                case 24:
                                case 26:
                                    nDc = HUtil32.HiWord(StdItem80.DC) + HUtil32.LoWord(StdItem80.DC) + 1;
                                    nSc = HUtil32.HiWord(StdItem80.SC) + HUtil32.LoWord(StdItem80.SC) + 1;
                                    nMc = HUtil32.HiWord(StdItem80.MC) + HUtil32.LoWord(StdItem80.MC) + 1;
                                    break;
                            }
                            if (nDcMin < nDc)
                            {
                                nDcMax = nDcMin;
                                nDcMin = nDc;
                            }
                            else
                            {
                                if (nDcMax < nDc)
                                {
                                    nDcMax = nDc;
                                }
                            }
                            if (nScMin < nSc)
                            {
                                nScMax = nScMin;
                                nScMin = nSc;
                            }
                            else
                            {
                                if (nScMax < nSc)
                                {
                                    nScMax = nSc;
                                }
                            }
                            if (nMcMin < nMc)
                            {
                                nMcMax = nMcMin;
                                nMcMin = nMc;
                            }
                            else
                            {
                                if (nMcMax < nMc)
                                {
                                    nMcMax = nMc;
                                }
                            }
                            if (DelItemList == null)
                            {
                                DelItemList = new List<string>();
                            }
                            //DelItemList.Add(HUtil32.SBytePtrToString(StdItem.Name,0,StdItem.NameLen), ((UserItem.MakeIndex) as Object));
                            if (StdItem.NeedIdentify == 1)
                            {
                                M2Share.AddGameDataLog("26" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09"
                                    + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09" + (UserItem.MakeIndex).ToString()
                                    + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString()
                                    + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")"
                                    + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/"
                                    + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/"
                                    + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/"
                                    + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/"
                                    + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09" + "0");
                            }
                            UserItem = null;
                            this.m_ItemList.RemoveAt(i);
                        }
                    }
                }
            }
            if (DuraList.Count > 0)
            {
                for (int i = 0; i < DuraList.Count; i++)
                {
                    if (DuraList.Count <= 0)
                    {
                        break;
                    }
                    for (int II = DuraList.Count - 1; II > i; II--)
                    {
                        //if (((int)DuraList[II]) > ((int)DuraList[II - 1]))
                        //{
                        //    DuraList.Exchange(II, II - 1);
                        //}
                    }
                }
                for (int i = 0; i < DuraList.Count; i++)
                {
                    nDura = nDura + ((int)DuraList[i]);
                    nItemCount++;
                    if (nItemCount >= 5)
                    {
                        break;
                    }
                }
            }
            btDura = (byte)HUtil32.Round(HUtil32._MIN(5, nItemCount) + HUtil32._MIN(5, nItemCount) * ((nDura / nItemCount) / 5.0));
            btDc = Convert.ToByte(nDcMin / 5 + nDcMax / 3);
            btSc = Convert.ToByte(nScMin / 5 + nScMax / 3);
            btMc = Convert.ToByte(nMcMin / 5 + nMcMax / 3);
            if (DelItemList != null)
            {
                Console.WriteLine("todo RM_SENDDELITEMLIST...");
                //this.SendMsg(this, Grobal2.RM_SENDDELITEMLIST, 0, DelItemList.ToInt(), 0, 0, "");
            }
            if (DuraList != null)
            {
                Dispose(DuraList);
            }
        }

        public override string GeTBaseObjectInfo()
        {
            string result = string.Empty;
            result = this.m_sCharName + " 标识:" + this.m_ActorsId + " 权限等级: " + (this.m_btPermission).ToString() + " 管理模式: "
            + HUtil32.BoolToCStr(this.m_boAdminMode) + " 隐身模式: " + HUtil32.BoolToCStr(this.m_boObMode) + " 无敌模式: " + HUtil32.BoolToCStr(this.m_boSuperMan)
                + " 地图:" + this.m_sMapName + "(" + this.m_PEnvir.sMapDesc + ")" + " 座标:" + (this.m_nCurrX).ToString() + ":" + (this.m_nCurrY).ToString() + " 等级:"
                + (this.m_Abil.Level).ToString() + " 转生等级:" + (m_btReLevel).ToString() + " 经验:" + (this.m_Abil.Exp).ToString() + " 生命值: " + (this.m_WAbil.HP).ToString()
                + "-" + (this.m_WAbil.MaxHP).ToString() + " 魔法值: " + (this.m_WAbil.MP).ToString() + "-" + (this.m_WAbil.MaxMP).ToString() + " 攻击力: "
                + (HUtil32.LoWord(this.m_WAbil.DC)).ToString() + "-" + (HUtil32.HiWord(this.m_WAbil.DC)).ToString() + " 魔法力: " + (HUtil32.LoWord(this.m_WAbil.MC)).ToString()
                + "-" + (HUtil32.HiWord(this.m_WAbil.MC)).ToString() + " 道术: " + (HUtil32.LoWord(this.m_WAbil.SC)).ToString() + "-" + (HUtil32.HiWord(this.m_WAbil.SC)).ToString()
                + " 防御力: " + (HUtil32.LoWord(this.m_WAbil.AC)).ToString() + "-" + (HUtil32.HiWord(this.m_WAbil.AC)).ToString() + " 魔防力: "
                + (HUtil32.LoWord(this.m_WAbil.MAC)).ToString() + "-" + (HUtil32.HiWord(this.m_WAbil.MAC)).ToString() + " 准确:" + (this.m_btHitPoint).ToString() + " 敏捷:"
                + (this.m_btSpeedPoint).ToString() + " 速度:" + (this.m_nHitSpeed).ToString() + " 仓库密码:" + m_sStoragePwd + " 登录IP:" + m_sIPaddr + "(" + m_sIPLocal + ")"
                + " 登录帐号:" + m_sUserID + " 登录时间:" + (m_dLogonTime).ToString() + " 在线时长(分钟):" + ((HUtil32.GetTickCount() - m_dwLogonTick) / 60000).ToString()
                + " 登录模式:" + (m_nPayMent).ToString() + " " + M2Share.g_Config.sGameGoldName + ":" + (m_nGameGold).ToString() + " " + M2Share.g_Config.sGameDiaMond + ":"
                + (m_nGAMEDIAMOND).ToString() + " " + M2Share.g_Config.sGameGird + ":" + (m_nGAMEGIRD).ToString() + " " + M2Share.g_Config.sGamePointName + ":"
                + (m_nGamePoint).ToString()
                + " " + M2Share.g_Config.sPayMentPointName + ":" + (m_nPayMentPoint).ToString() + " 会员类型:" + (m_nMemberType).ToString() + " 会员等级:"
                + (m_nMemberLevel).ToString() + " 经验倍数:" + (m_nKillMonExpRate / 100).ToString() + " 攻击倍数:" + (m_nPowerRate / 100).ToString() + " 声望值:"
                + (m_btCreditPoint).ToString();
            return result;
        }

        public unsafe int GetDigUpMsgCount()
        {
            int result = 0;
            TSendMessage* SendMessage = null;
            try
            {
                HUtil32.EnterCriticalSection(M2Share.ProcessMsgCriticalSection);
                if (this.m_MsgList.Count > 0)
                {
                    for (int i = 0; i < this.m_MsgList.Count; i++)
                    {
                        SendMessage = (TSendMessage*)this.m_MsgList[i];
                        if (SendMessage != null)
                        {
                            if ((SendMessage->wIdent == Grobal2.CM_BUTCH))
                            {
                                result++;
                            }
                        }
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.ProcessMsgCriticalSection);
            }
            return result;
        }

        // 取玩家的等级排名
        public int GetUserLevelOrder()
        {
            int result;
            int nIndex;
            List<string> PlayLevelOrder;
            string sCharName;
            string CharName;
            result = 0;
            //EnterCriticalSection(M2Share.HumanSortCriticalSection);
            //try
            //{
            //    PlayLevelOrder = M2Share.GetPlayObjectOrderList(0);
            //    if (PlayLevelOrder != null)
            //    {
            //        if (PlayLevelOrder.Count > 0)
            //        {
            //            for (nIndex = 0; nIndex < PlayLevelOrder.Count; nIndex++)
            //            {
            //                CharName = ((string[])(PlayLevelOrder.Values[nIndex]));
            //                sCharName = CharName;
            //                if ((this.m_sCharName).ToLower().CompareTo((sCharName).ToLower()) == 0)
            //                {
            //                    result = nIndex + 1;
            //                    break;
            //                }
            //            }
            //        }
            //    }
            //}
            //finally
            //{
            //    LeaveCriticalSection(M2Share.HumanSortCriticalSection);
            //}
            return result;
        }

        // 获取人物等级排行  NPC
        public string UserLevelOrder_Add_space(string Str, int Size)
        {
            string result;
            result = Str;
            if (Str.Length >= Size)
            {
                return result;
            }
            while (result.Length < Size)
            {
                result = result + " ";
            }
            return result;
        }

        private void UserLevelOrder(int BaseObject)
        {
            int nIndex;
            int nPage;
            string sIndex;
            string sCharName = string.Empty;
            string sLevel;
            List<string> PlayObjectList = null;
            bool boFound;
            int n01;
            int n02;
            string s01;
            TMerchant Merchant;
            string CharName;
            const string sFirstStr1 = "序位                  角色名                      等级\\";
            const string sFirstStr2 = "序位                  角色名                出师徒弟数\\";
            const string sNotFoundStr = "您没有上榜或不在该榜！！！\\";
            HUtil32.EnterCriticalSection(M2Share.HumanSortCriticalSection);
            try
            {
                m_PlayOrderList.Clear();
                if (m_nSelPlayOrderType == 4)
                {
                    m_PlayOrderList.Add(sFirstStr2);
                }
                else
                {
                    m_PlayOrderList.Add(sFirstStr1);
                }
                // PlayObjectList = M2Share.GetPlayObjectOrderList(m_nSelPlayOrderType);
                nPage = m_nPlayOrderPage;
                if (PlayObjectList != null)
                {
                    if (m_boGetMyLevelOrder)// 我的排行
                    {
                        m_boGetMyLevelOrder = false;
                        boFound = false;
                        if (PlayObjectList.Count > 0)
                        {
                            for (nIndex = 0; nIndex < PlayObjectList.Count; nIndex++)
                            {
                                // CharName = ((string[])(PlayObjectList.Values[nIndex]));
                                //sCharName = CharName;
                                if ((this.m_sCharName).ToLower().CompareTo((sCharName).ToLower()) == 0)
                                {
                                    sIndex = (nIndex + 1).ToString();
                                    sLevel = PlayObjectList[nIndex];
                                    sIndex = UserLevelOrder_Add_space(sIndex, 4 + 18);
                                    sCharName = UserLevelOrder_Add_space(sCharName, 14 + 14);
                                    m_PlayOrderList.Add(sIndex + sCharName + sLevel + "\\");
                                    boFound = true;
                                    break;
                                }
                            }
                        }
                        if (!boFound)
                        {
                            m_PlayOrderList.Clear();
                            m_PlayOrderList.Add(sNotFoundStr);
                        }
                    }
                    else
                    {
                        n01 = 0;
                        if (nPage > 0)
                        {
                            for (nIndex = nPage * 7; nIndex < PlayObjectList.Count; nIndex++)
                            {
                                if (n01 >= 7)
                                {
                                    break;
                                }
                                sIndex = (nIndex + 1).ToString();
                                //CharName = ((string[])(PlayObjectList.Values[nIndex]));
                                //sCharName = CharName;
                                sLevel = PlayObjectList[nIndex];
                                sIndex = UserLevelOrder_Add_space(sIndex, 4 + 18);
                                sCharName = UserLevelOrder_Add_space(sCharName, 14 + 14);
                                m_PlayOrderList.Add(sIndex + sCharName + sLevel + "\\");
                                n01++;
                            }
                        }
                        else
                        {
                            if (PlayObjectList.Count > 0)
                            {
                                for (nIndex = 0; nIndex < PlayObjectList.Count; nIndex++)
                                {
                                    if (n01 >= 7)
                                    {
                                        break;
                                    }
                                    sIndex = (nIndex + 1).ToString();
                                    //CharName = ((string[])(PlayObjectList.Values[nIndex]));
                                    //sCharName = CharName;
                                    sLevel = PlayObjectList[nIndex];
                                    sIndex = UserLevelOrder_Add_space(sIndex, 4 + 18);
                                    sCharName = UserLevelOrder_Add_space(sCharName, 14 + 14);
                                    m_PlayOrderList.Add(sIndex + sCharName + sLevel + "\\");
                                    n01++;
                                }
                            }
                        }
                    }
                }
                if (m_PlayOrderList.Count > 0)
                {
                    n02 = 8 - m_PlayOrderList.Count;
                    if (n02 > 0)
                    {
                        for (nIndex = 1; nIndex <= n02; nIndex++)
                        {
                            s01 = m_PlayOrderList[m_PlayOrderList.Count - 1];
                            m_PlayOrderList[m_PlayOrderList.Count - 1] = s01 + " \\";
                        }
                    }
                }
                Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(BaseObject);
                if (Merchant != null)
                {
                    Merchant.GotoLable(this, "@LevelOrder", false);
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.HumanSortCriticalSection);
            }
        }

        public void GoldChange(string sChrName, int nGold)
        {
            string s10;
            string s14;
            if (nGold > 0)
            {
                s10 = "14";
                s14 = "增加完成";
            }
            else
            {
                s10 = "13";
                s14 = "以删减";
            }
            this.SysMsg(sChrName + " 的金币 " + (nGold).ToString() + " 金币" + s14, TMsgColor.c_Green, TMsgType.t_Hint);
            if (M2Share.g_boGameLogGold)
            {
                M2Share.AddGameDataLog(s10 + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString()
                    + "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME + "\09" + (nGold).ToString() + "\09" + "1" + "\09" + sChrName);
            }
        }

        public void ClearStatusTime()
        {
            for (int i = 0; i < this.m_wStatusTimeArr.Length; i++)
            {
                this.m_wStatusTimeArr[i] = 0;
            }
        }

        /// <summary>
        /// 发送地图音乐背景数据
        /// </summary>
        private void SendMapDescription()
        {
            int nMUSICID = -1;
            string sMUSINAME = string.Empty;
            if (this.m_PEnvir.m_boMUSIC)
            {
                nMUSICID = this.m_PEnvir.m_nMUSICID;
                sMUSINAME = this.m_PEnvir.m_sMUSICName;
            }
            if (nMUSICID >= 0)
            {
                SendDefMessage(Grobal2.SM_MAPDESCRIPTION, nMUSICID, 0, 0, 0, this.m_PEnvir.sMapDesc);
            }
            else
            {
                SendDefMessage(Grobal2.SM_MAPDESCRIPTION, -1, 0, 0, 0, this.m_PEnvir.sMapDesc + '\r' + sMUSINAME);
            }
            if (this.m_PEnvir.m_boMUSIC)
            {
                nMUSICID = this.m_PEnvir.m_nMUSICID;
            }
            SendDefMessage(Grobal2.SM_MAPDESCRIPTION, nMUSICID, 0, 0, 0, this.m_PEnvir.sMapDesc);
        }

        private void ClientRushPulse(ushort PulsePage, ushort RushLevel, bool IsHero)
        {
            if ((PulsePage >= 0 && PulsePage <= 3) && (RushLevel >= 1 && RushLevel <= 5))
            {
                if (IsHero)
                {
                    if (m_MyHero != null)// 英雄经络
                    {
                        if (m_MyHero.m_HumPulses[PulsePage].PulseLevel == RushLevel - 1)
                        {
                            if (M2Share.g_BatterNPC != null)
                            {
                                M2Share.g_BatterNPC.GotoLable(this, "@Hero修炼" + PulsePage + "-" + (RushLevel - 1).ToString(), false);
                            }
                        }
                    }
                }
                else
                {
                    if (this.m_HumPulses[PulsePage].PulseLevel == RushLevel - 1)
                    {
                        if (M2Share.g_BatterNPC != null)
                        {
                            M2Share.g_BatterNPC.GotoLable(this, "@经络修炼" + PulsePage + "-" + (RushLevel - 1).ToString(), false);
                        }
                    }
                }
            }
        }

        /// <summary>
        /// 向客户端发送游戏币,游戏点,金刚石,灵符数量
        /// </summary>
        /// <param name="boSendName"></param>
        private void SendGoldInfo(bool boSendName)
        {
            string sMsg = string.Empty;
            if (boSendName)
            {
                sMsg = M2Share.g_Config.sGameGoldName + '\r' + M2Share.g_Config.sGamePointName + '\r' + M2Share.g_Config.sGameDiaMond + '\r' + M2Share.g_Config.sGameGird;
            }
            SendDefMessage(Grobal2.SM_GAMEGOLDNAME, m_nGameGold, m_nGamePoint, m_nGAMEDIAMOND, m_nGAMEGIRD, sMsg);
        }

        /// <summary>
        /// 发送荣誉值
        /// </summary>
        private void SendGloryInfo()
        {
            SendDefMessage(Grobal2.SM_GLORY, m_btGameGlory, 0, 0, 0, "");
        }

        /// <summary>
        /// 发送服务器配置信息(客户端相关)
        /// </summary>
        public unsafe void SendServerConfig()
        {
            int nRecog;
            int nParam;
            string sMsg;
            TClientConf ClientConf;
            if (m_nSoftVersionDateEx == 0)
            {
                return;
            }
            byte nRunHuman = 0;
            byte nRunMon = 0;
            byte nRunNpc = 0;
            byte nWarRunAll = 0;
            if (M2Share.g_Config.boDiableHumanRun || ((this.m_btPermission > 9) && M2Share.g_Config.boGMRunAll) || (M2Share.g_Config.boSafeAreaLimited && this.InSafeZone()))
            {
                nRunHuman = 1;
                nRunMon = 1;
                nRunNpc = 1;
                nWarRunAll = 1;
            }
            else
            {
                if (M2Share.g_Config.boRUNHUMAN || this.m_PEnvir.m_boRUNHUMAN)
                {
                    nRunHuman = 1;
                }
                if (M2Share.g_Config.boRUNMON || this.m_PEnvir.m_boRUNMON)
                {
                    nRunMon = 1;
                }
                if (M2Share.g_Config.boRunNpc)
                {
                    nRunNpc = 1;
                }
                if (M2Share.g_Config.boWarDisHumRun)
                {
                    nWarRunAll = 1;
                }
            }
            ClientConf = M2Share.g_Config.ClientConf;
            //TClientConf ClientConf = new TClientConf();
            ClientConf.boRUNHUMAN = nRunHuman == 1;
            ClientConf.boRUNMON = nRunMon == 1;
            ClientConf.boRunNpc = nRunNpc == 1;
            ClientConf.boWarRunAll = nWarRunAll == 1;
            ClientConf.wSpellTime = Convert.ToUInt16(M2Share.g_Config.dwMagicHitIntervalTime + 300);
            ClientConf.wHitIime = Convert.ToUInt16(M2Share.g_Config.dwHitIntervalTime + 500);//攻击速度
            ClientConf.boSkill31Effect = M2Share.g_Config.boSkill31Effect;// 魔法盾效果 T-特色效果 F-盛大效果
            sMsg = EncryptUnit.EncodeBuffer(&ClientConf, sizeof(TClientConf));
            nRecog = HUtil32.MakeLong(HUtil32.MakeWord(nRunHuman, nRunMon), HUtil32.MakeWord(nRunNpc, nWarRunAll));
            nParam = HUtil32.MakeWord(ClientConf.btDieColor, 0);
            SendDefMessage(Grobal2.SM_SERVERCONFIG, nRecog, nParam, 0, 0, sMsg);
        }

        /// <summary>
        /// 发送解包内容
        /// </summary>
        private void SendUnBind()
        {
            TUnbindInfo UnbindInfo;
            string sMsg = string.Empty;
            if (M2Share.g_UnbindList.Count > 0)
            {
                for (int i = 0; i < M2Share.g_UnbindList.Count; i++)
                {
                    UnbindInfo = M2Share.g_UnbindList[i];
                    sMsg = sMsg + EncryptUnit.EncodeBuffer(UnbindInfo) + "/";
                }
            }
            if (!string.IsNullOrEmpty(sMsg))
            {
                TDefaultMessage  msg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SERVERUNBIND, 0, 0, 0, 0, 0);
                SendSocket(msg, sMsg); //修正发送消息错误，导致客户端认为是发送服务端配置消息，造成玩家无法多次攻击目标
            }
        }

        private void SendServerStatus()
        {
            if (this.m_btPermission < 10)
            {
                return;
            }
            // this.SysMsg((EDcodeUnit.Units.EDcodeUnit.CalcFileCRC(System.Environment.GetCommandLineArgs()[0])).ToString(), TMsgColor.c_Red, TMsgType.t_Hint);
        }

        /// <summary>
        /// 发送使用的物品
        /// </summary>
        public unsafe void SendUseitems()
        {
            TStdItem Item;
            string sSENDMSG = string.Empty;
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            TStdItem StdItem;
            string sUserItemName;
            if ((m_nSoftVersionDateEx == 0) && (m_dwClientTick == 0))
            {
                for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                {
                    if (this.m_UseItems[i] != null && this.m_UseItems[i].wIndex > 0)
                    {
                        Item = M2Share.UserEngine.GetStdItem(this.m_UseItems[i].wIndex);
                        if (Item != null)
                        {
                            StdItem = Item;
                            M2Share.ItemUnit.GetItemAddValue(this.m_UseItems[i], StdItem);
                            M2Share.CopyStdItemToOStdItem(StdItem, &OClientItem->s);  // 取自定义物品名称
                            sUserItemName = "";
                            if (this.m_UseItems[i].btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(this.m_UseItems[i].MakeIndex, this.m_UseItems[i].wIndex);
                            }
                            if (sUserItemName != "")
                            {
                                HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                                //OClientItem->s->Name = sUserItemName;
                            }
                            OClientItem->Dura = this.m_UseItems[i].Dura;
                            OClientItem->DuraMax = this.m_UseItems[i].DuraMax;
                            OClientItem->MakeIndex = this.m_UseItems[i].MakeIndex;
                            byte[] data = new byte[sizeof(TOClientItem)];
                            fixed (byte* pb = data)
                            {
                                *(TOClientItem*)pb = *OClientItem;
                            }
                            sSENDMSG = sSENDMSG + i + "/" + EncryptUnit.EncodeBuffer(data, sizeof(TOClientItem)) + "/";
                        }
                    }
                }
                if (sSENDMSG != "")
                {
                    this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDUSEITEMS, 0, 0, 0, 0, 0);
                    SendSocket(this.m_DefMsg, sSENDMSG);
                }
            }
            else
            {
                for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                {
                    if (this.m_UseItems[i] != null && this.m_UseItems[i].wIndex > 0)
                    {
                        Item = M2Share.UserEngine.GetStdItem(this.m_UseItems[i].wIndex);
                        if (Item != null)
                        {
                            StdItem = Item;
                            M2Share.ItemUnit.GetItemAddValue(this.m_UseItems[i], StdItem);
                            ClientItem = new TClientItem
                            {
                                s = StdItem
                            };
                            sUserItemName = "";// 取自定义物品名称
                            if (this.m_UseItems[i].btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(this.m_UseItems[i].MakeIndex, this.m_UseItems[i].wIndex);
                            }
                            if (sUserItemName != "")
                            {
                                ClientItem.s.Name = sUserItemName;
                            }
                            if (this.m_UseItems[i].btValue[12] == 1) // 物品发光
                            {
                                ClientItem.s.Reserved1 = 1;
                            }
                            else
                            {
                                ClientItem.s.Reserved1 = 0;
                            }
                        }
                        ClientItem.Dura = this.m_UseItems[i].Dura;
                        ClientItem.DuraMax = this.m_UseItems[i].DuraMax;
                        ClientItem.MakeIndex = this.m_UseItems[i].MakeIndex;
                        sSENDMSG = sSENDMSG + i + "/" + EncryptUnit.EncodeBuffer(ClientItem) + "/";
                    }
                }
                if (sSENDMSG != "")
                {
                    this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDUSEITEMS, 0, 0, 0, 0, 0);
                    SendSocket(this.m_DefMsg, sSENDMSG);
                }
            }
        }

        /// <summary>
        /// 发送使用的魔法
        /// </summary>
        private void SendUseMagic()
        {
            string sSENDMSG = "";
            TUserMagic UserMagic;
            TClientMagic ClientMagic = null;
            if (this.m_MagicList.Count > 0)
            {
                for (int i = 0; i < this.m_MagicList.Count; i++)
                {
                    UserMagic = this.m_MagicList[i];
                    if (UserMagic != null)
                    {
                        ClientMagic = new TClientMagic();
                        ClientMagic.Key = (char)(UserMagic.btKey);
                        ClientMagic.Level = UserMagic.btLevel;
                        ClientMagic.CurTrain = UserMagic.nTranPoint;
                        ClientMagic.Def = UserMagic.MagicInfo;
                        sSENDMSG = sSENDMSG + EncryptUnit.EncodeBuffer(ClientMagic) + "/";
                    }
                }
            }
            if (sSENDMSG != "")
            {
                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDMYMAGIC, 0, 0, 0, this.m_MagicList.Count, 0);
                SendSocket(this.m_DefMsg, sSENDMSG);
            }
        }

        /// <summary>
        /// 客户端改变方向
        /// </summary>
        /// <returns></returns>
        private bool ClientChangeDir(int wIdent, int nX, int nY, int nDir, ref uint dwDelayTime)
        {
            bool result = false;
            uint dwCheckTime;
            if (this.m_boDeath || (this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0))// 防麻
            {
                return result;
            }
            if (!CheckActionStatus(wIdent, ref dwDelayTime))
            {
                m_boFilterAction = false;
                return result;
            }
            m_boFilterAction = true;
            dwCheckTime = HUtil32.GetTickCount() - m_dwTurnTick;
            if (dwCheckTime < M2Share.g_Config.dwTurnIntervalTime)
            {
                dwDelayTime = M2Share.g_Config.dwTurnIntervalTime - dwCheckTime;
                return result;
            }
            if ((nX == this.m_nCurrX) && (nY == this.m_nCurrY))
            {
                this.m_btDirection = (byte)nDir;
                if (this.Walk(Grobal2.RM_TURN))
                {
                    m_dwTurnTick = HUtil32.GetTickCount();
                    result = true;
                }
            }
            return result;
        }

        /// <summary>
        /// 客户端蹲下的动作
        /// </summary>
        /// <returns></returns>
        private bool ClientSitDownHit(int nX, int nY, int nDir, ref uint dwDelayTime)
        {
            bool result = false;
            uint dwCheckTime;
            if (this.m_boDeath || (this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0))// 防麻
            {
                return result;
            }
            dwCheckTime = HUtil32.GetTickCount() - m_dwTurnTick;
            if (dwCheckTime < M2Share.g_Config.dwTurnIntervalTime)
            {
                dwDelayTime = M2Share.g_Config.dwTurnIntervalTime - dwCheckTime;
                return result;
            }
            m_dwTurnTick = HUtil32.GetTickCount();
            this.SendRefMsg(Grobal2.RM_POWERHIT, 0, 0, 0, 0, "");
            result = true;
            return result;
        }

        /// <summary>
        /// 开门,人物走到地图的某个过门点时
        /// </summary>
        private void ClientOpenDoor(int nX, int nY)
        {
            TDoorInfo Door = this.m_PEnvir.GetDoor(nX, nY);
            TUserCastle Castle;
            if (Door == null)
            {
                return;
            }
            Castle = M2Share.g_CastleManager.IsCastleEnvir(this.m_PEnvir);
            if ((Castle == null) || (Castle.m_DoorStatus != Door.Status) || (this.m_btRaceServer != Grobal2.RC_PLAYOBJECT)
                || Castle.CheckInPalace(this.m_nCurrX, this.m_nCurrY, this))
            {
                M2Share.UserEngine.OpenDoor(this.m_PEnvir, nX, nY);
            }
        }

        /// <summary>
        /// 取能走的坐标
        /// </summary>
        /// <returns></returns>
        public bool MakeHero_GetGotoXY(int nDir, ref int nX, ref int nY)
        {
            bool result = false;
            byte n01 = 0;
            int nTargetX = nX;
            int nTargetY = nY;
            while (true)
            {
                switch (nDir)
                {
                    case Grobal2.DR_UP:// 北
                        if (this.m_PEnvir.CanWalk(nTargetX, nTargetY, false))
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            if (n01 >= 3)
                            {
                                break;
                            }
                            nTargetY -= 2;
                            n01++;
                            continue;
                        }
                    case Grobal2.DR_UPRIGHT:// 东北
                        if (this.m_PEnvir.CanWalk(nTargetX, nTargetY, false))
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            if (n01 >= 3)
                            {
                                break;
                            }
                            nTargetX += 2;
                            nTargetY -= 2;
                            n01++;
                            continue;
                        }
                    case Grobal2.DR_RIGHT:// 东
                        if (this.m_PEnvir.CanWalk(nTargetX, nTargetY, false))
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            if (n01 >= 3)
                            {
                                break;
                            }
                            nTargetX += 2;
                            n01++;
                            continue;
                        }
                    case Grobal2.DR_DOWNRIGHT:// 东南
                        if (this.m_PEnvir.CanWalk(nTargetX, nTargetY, false))
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            if (n01 >= 3)
                            {
                                break;
                            }
                            nTargetX += 2;
                            nTargetY += 2;
                            n01++;
                            continue;
                        }
                    case Grobal2.DR_DOWN:// 南
                        if (this.m_PEnvir.CanWalk(nTargetX, nTargetY, false))
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            if (n01 >= 3)
                            {
                                break;
                            }
                            nTargetY += 1;
                            n01++;
                            continue;
                        }
                    case Grobal2.DR_DOWNLEFT:// 西南
                        if (this.m_PEnvir.CanWalk(nTargetX, nTargetY, false))
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            if (n01 >= 3)
                            {
                                break;
                            }
                            nTargetX -= 2;
                            nTargetY += 2;
                            n01++;
                            continue;
                        }
                    case Grobal2.DR_LEFT:// 西
                        if (this.m_PEnvir.CanWalk(nTargetX, nTargetY, false))
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            if (n01 >= 3)
                            {
                                break;
                            }
                            nTargetX -= 2;
                            n01++;
                            continue;
                        }
                    case Grobal2.DR_UPLEFT:// 西北向
                        if (this.m_PEnvir.CanWalk(nTargetX, nTargetY, false))
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            if (n01 >= 3)
                            {
                                break;
                            }
                            nTargetX -= 2;
                            nTargetY -= 2;
                            n01++;
                            continue;
                        }
                    default:
                        break;
                }
                nX = nTargetX;
                nY = nTargetY;
                return result;
            }
        }

        // 用户排行
        public List<string> ClientGetUserOrder_GetSortStringList(int nSortType, int nType)
        {
            List<string> result;
            result = null;
            switch (nSortType)
            {
                case 0:
                    switch (nType)
                    {
                        case 1:
                            // result = M2Share.UserEngine.m_PlayObjectLevelList;
                            break;
                        case 2:
                            // result = M2Share.UserEngine.m_WarrorObjectLevelList;
                            break;
                        case 3:
                            // result = M2Share.UserEngine.m_WizardObjectLevelList;
                            break;
                        case 4:
                            // result = M2Share.UserEngine.m_TaoistObjectLevelList;
                            break;
                    }
                    break;
                case 1:
                    switch (nType)
                    {
                        case 1:
                            // result = M2Share.UserEngine.m_HeroObjectLevelList;
                            break;
                        case 2:
                            //result = M2Share.UserEngine.m_WarrorHeroObjectLevelList;
                            break;
                        case 3:
                            // result = M2Share.UserEngine.m_WizardHeroObjectLevelList;
                            break;
                        case 4:
                            // result = M2Share.UserEngine.m_TaoistHeroObjectLevelList;
                            break;
                    }
                    break;
                case 2:
                    // result = M2Share.UserEngine.m_PlayObjectMasterList;
                    break;
            }
            return result;
        }

        public int ClientGetUserOrder_GetPageCount(List<string> List)
        {
            int result;
            result = List.Count / 10;
            if (List.Count % 10 > 0)
            {
                result++;
            }
            return result;
        }

        // nSortType 0-人物榜 1-英雄榜 2-师徒榜
        // nType 1-等级榜 2-战士榜 3-法师榜 4-道士榜
        private void ClientGetUserOrder(int nSortType, int nType, int nPage)
        {
            string sCharName = string.Empty;
            string sHeroName = string.Empty;
            int nIndex;
            List<string> StringList;
            int n01;
            int nPageCount;
            int nBeginPage;
            string sSendText;
            TUserLevelSort UserLevelSort = null;
            THeroLevelSort HeroLevelSort = null;
            TUserMasterSort UserMasterSort = null;
            string CharName = string.Empty;
            string HeroName = string.Empty;
            byte nCode;
            HUtil32.EnterCriticalSection(M2Share.HumanSortCriticalSection);
            try
            {
                nCode = 0;
                try
                {
                    StringList = ClientGetUserOrder_GetSortStringList(nSortType, nType);
                    nCode = 1;
                    if (StringList != null)
                    {
                        n01 = 0;
                        sSendText = "";
                        nPageCount = ClientGetUserOrder_GetPageCount(StringList);
                        nCode = 2;
                        nBeginPage = nPage;
                        if (nPage >= nPageCount)
                        {
                            nBeginPage = nPageCount - 1;
                        }
                        if (nBeginPage < 0)
                        {
                            nBeginPage = 0;
                        }
                        if (nPage < 0)
                        {
                            // 我的排行
                            for (nIndex = 0; nIndex < StringList.Count; nIndex++)
                            {
                                sCharName = "";
                                nCode = 3;
                                if (nSortType == 1)
                                {
                                    //HeroName = ((string[])(StringList[nIndex]));
                                    if (HeroName != null)
                                    {
                                        sHeroName = HeroName;
                                    }
                                    sHeroName = HUtil32.GetValidStr3(sHeroName, ref sCharName, new string[] { "\r" });
                                }
                                else
                                {
                                    CharName = StringList[nIndex];
                                    if (CharName != null)
                                    {
                                        sCharName = CharName;
                                    }
                                }
                                nCode = 4;
                                if ((sCharName != "") && (sCharName == this.m_sCharName))
                                {
                                    switch (nSortType)
                                    {
                                        case 0:
                                            nCode = 5;
                                            //UserLevelSort.nIndex = nIndex + 1;
                                            //UserLevelSort.wLevel = HUtil32.Str_ToInt(StringList[nIndex], 0);
                                            // 20081222
                                            if (UserLevelSort.wLevel > 0)
                                            {
                                                //UserLevelSort.sChrName = sCharName;
                                                //sSendText = sSendText + EncryptUnit.EncodeBuffer(UserLevelSort, sizeof(TUserLevelSort)) + "/";
                                            }
                                            break;
                                        case 1:
                                            nCode = 6;
                                            // HeroLevelSort.nIndex = nIndex + 1;
                                            //HeroLevelSort.wLevel = HUtil32.Str_ToInt(StringList[nIndex], 0);
                                            // 20081222
                                            if (HeroLevelSort.wLevel > 0)
                                            {
                                                HeroLevelSort.sChrName = sCharName;
                                                HeroLevelSort.sHeroName = sHeroName;
                                                //sSendText = sSendText + EncryptUnit.EncodeBuffer(HeroLevelSort, sizeof(THeroLevelSort)) + "/";
                                            }
                                            break;
                                        case 2:
                                            nCode = 7;
                                            // UserMasterSort.nIndex = nIndex + 1;
                                            // UserMasterSort.nMasterCount := StrToInt(StringList.Strings[nIndex]);
                                            UserMasterSort.nMasterCount = HUtil32.Str_ToInt(StringList[nIndex], 0);
                                            // 20081222
                                            if (UserMasterSort.nMasterCount > 0)
                                            {
                                                //UserMasterSort.sChrName = CharName;
                                                //sSendText = sSendText + EncryptUnit.EncodeBuffer(UserMasterSort, sizeof(TUserMasterSort)) + "/";
                                            }
                                            break;
                                    }
                                    break;
                                }
                            }
                        }
                        else
                        {
                            nCode = 8;
                            for (nIndex = nBeginPage * 10; nIndex < StringList.Count; nIndex++)
                            {
                                if (n01 >= 10)
                                {
                                    break;
                                }
                                switch (nSortType)
                                {
                                    case 0:
                                        nCode = 9;
                                        UserLevelSort.nIndex = nIndex + 1;
                                        nCode = 95;
                                        //UserLevelSort.wLevel = HUtil32.Str_ToInt(StringList[nIndex], 0);
                                        nCode = 92;
                                        //CharName = ((string[])(StringList.Values[nIndex]));
                                        if ((CharName != null) && (UserLevelSort.wLevel > 0))
                                        {
                                            // 20081204
                                            nCode = 93;
                                            // UserLevelSort.sChrName = CharName;
                                            nCode = 94;
                                            //sSendText = sSendText + EncryptUnit.EncodeBuffer(UserLevelSort, sizeof(TUserLevelSort)) + "/";
                                        }
                                        break;
                                    case 1:
                                        nCode = 10;
                                        HeroLevelSort.nIndex = nIndex + 1;
                                        nCode = 108;
                                        //HeroLevelSort.wLevel = HUtil32.Str_ToInt(StringList[nIndex], 0);
                                        nCode = 102;
                                        // HeroName = ((string[])(StringList.Values[nIndex]));
                                        nCode = 103;
                                        if ((HeroName != null) && (HeroLevelSort.wLevel > 0))
                                        {
                                            nCode = 104;
                                            sHeroName = HeroName;
                                            nCode = 105;
                                            sHeroName = HUtil32.GetValidStr3(sHeroName, ref sCharName, new string[] { "\r" });
                                            nCode = 106;
                                            HeroLevelSort.sChrName = sCharName;
                                            HeroLevelSort.sHeroName = sHeroName;
                                            nCode = 107;
                                            //sSendText = sSendText + EncryptUnit.EncodeBuffer(HeroLevelSort, sizeof(THeroLevelSort)) + "/";
                                        }
                                        break;
                                    case 2:
                                        nCode = 11;
                                        UserMasterSort.nIndex = nIndex + 1;
                                        // UserMasterSort.nMasterCount := StrToInt(StringList.Strings[nIndex]);
                                        UserMasterSort.nMasterCount = HUtil32.Str_ToInt(StringList[nIndex], 0);
                                        if (UserMasterSort.nMasterCount > 0)
                                        {
                                            //CharName = ((string[])(StringList[nIndex]));
                                            UserMasterSort.sChrName = CharName;
                                            // sSendText = sSendText + EncryptUnit.EncodeBuffer(UserMasterSort, sizeof(TUserMasterSort)) + "/";
                                        }
                                        break;
                                }
                                n01++;
                            }
                        }
                        nCode = 12;
                        if (nPage >= 0)
                        {
                            nCode = 13;
                            if (sSendText != "")
                            {
                                // 客户端对应Param   Recog     Tag     Series
                                this.SendMsg(this, Grobal2.RM_QUERYUSERLEVELSORT, nPage, nSortType, nType, nPageCount, sSendText);
                            }
                        }
                        else
                        {
                            nCode = 14;
                            if (sSendText != "")
                            {
                                this.SendMsg(this, Grobal2.RM_QUERYUSERLEVELSORT, nPage, nSortType, nType, 0, sSendText);
                            }
                            else
                            {
                                this.SendMsg(this, Grobal2.RM_QUERYUSERLEVELSORT, nPage, -1, nType, 0, "");
                            }
                        }
                    }
                }
                catch
                {
                    M2Share.MainOutMessage("[异常] TPlayObject.ClientGetUserOrder Code:" + (nCode).ToString());
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.HumanSortCriticalSection);
            }
        }

        /// <summary>
        /// 人物:把包裹物品到身上
        /// </summary>
        public void ClientTakeOnItems(byte btWhere, int nItemIdx, string sItemName)
        {
            int n14;
            int n18;
            TUserItem UserItem;
            TUserItem TakeOffItem;
            TStdItem StdItem;
            TStdItem StdItem20;
            TStdItem StdItem58;
            string sUserItemName;
            TBaseObject Slave;
            StdItem = null;
            UserItem = null;
            n14 = -1;
            if (this.m_ItemList.Count > 0)
            {
                for (int i = 0; i < this.m_ItemList.Count; i++)
                {
                    UserItem = this.m_ItemList[i];
                    if ((UserItem != null) && (UserItem.MakeIndex == nItemIdx))// 取自定义物品名称
                    {
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                        if (UserItem.btValue[12] == 1)// 物品发光
                        {
                            StdItem.Reserved1 = 1;
                        }
                        else
                        {
                            StdItem.Reserved1 = 0;
                        }
                        if (StdItem != null)
                        {
                            if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                            {
                                n14 = i;
                                break;
                            }
                        }
                    }
                    UserItem = null;
                }
            }
            n18 = 0;
            if ((StdItem != null) && (UserItem != null))
            {
                if (this.CheckIsOKItem(UserItem, 0)) // 检查变态物品
                {
                    n18 = -1;
                    goto FailExit;
                }
                if ((btWhere == 13) && (M2Share.g_Config.nIsUseZhuLi > 1))// 如果没有设置人物可带,则不能带上斗笠
                {
                    n18 = -1;
                    goto FailExit;
                }
                if (M2Share.CheckUserItems(btWhere, StdItem))
                {
                    StdItem58 = StdItem;
                    M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem58);
                    if (CheckTakeOnItems(btWhere, StdItem58) && CheckItemBindUse(UserItem))
                    {
                        TakeOffItem = null;
                        if (btWhere >= 0 && btWhere <= 13)
                        {
                            if (this.m_UseItems[btWhere] != null && this.m_UseItems[btWhere].wIndex > 0)
                            {
                                StdItem20 = M2Share.UserEngine.GetStdItem(this.m_UseItems[btWhere].wIndex);
                                if (StdItem20 != null)
                                {
                                    switch (StdItem20.StdMode)
                                    {
                                        case 15:
                                        case 16:
                                        case 19:
                                        case 20:
                                        case 21:
                                        case 22:
                                        case 23:
                                        case 24:
                                        case 26:
                                            if ((!this.m_boUserUnLockDurg) && (this.m_UseItems[btWhere].btValue[7] != 0))
                                            {
                                                this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint); // '无法取下物品！！！'
                                                n18 = -4;
                                                goto FailExit;
                                            }
                                            break;
                                    }
                                }
                                if (!this.m_boUserUnLockDurg && ((StdItem20.Reserved & 2) != 0))
                                {
                                    // '无法取下物品！！！'
                                    this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    n18 = -4;
                                    goto FailExit;
                                }
                                if ((StdItem20.Reserved & 4) != 0)
                                {
                                    // '无法取下物品！！！'
                                    this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    n18 = -4;
                                    goto FailExit;
                                }
                                if (M2Share.InDisableTakeOffList(this.m_UseItems[btWhere].wIndex))
                                {
                                    // '无法取下物品！！！'
                                    this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    goto FailExit;
                                }
                                TakeOffItem = new TUserItem();// new TUserItem();//By Dr.Kevin修正此处没有申请内存地址，导致程序报错
                                TakeOffItem = this.m_UseItems[btWhere];
                            }
                            if (UserItem.btValue[8] != 0)
                            {
                                switch (StdItem.StdMode)
                                {
                                    case 15:
                                    case 16:
                                    case 19:
                                    case 26:
                                        UserItem.btValue[8] = 0;
                                        break;
                                }
                            }
                            this.m_UseItems[btWhere] = UserItem;
                            this.DelBagItem(n14);
                            if (TakeOffItem != null)
                            {
                                this.AddItemToBag(TakeOffItem);
                                SendAddItem(TakeOffItem);
                            }
                            RecalcAbilitys();
                            if (btWhere != Grobal2.U_BUJUK)// 物品位,不进入触发,以避免施毒术时不停的触发
                            {
                                this.CompareSuitItem(true);// 套装与身上装备对比
                            }
                            else
                            {
                                this.CompareSuitItem(false);
                            }
                            this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");
                            this.SendMsg(this, Grobal2.RM_SUBABILITY, 0, 0, 0, 0, "");
                            SendDefMessage(Grobal2.SM_TAKEON_OK, this.GetFeatureToLong(), this.GetFeatureEx(), 0, 0, "");
                            this.FeatureChanged();
                            if (StdItem.StdMode == 16) // 如果是斗笠则更新名字
                            {
                                this.RefShowName();  //宝宝也更新名字
                                if (this.m_SlaveList.Count > 0)
                                {
                                    for (int i = 0; i < this.m_SlaveList.Count; i++)
                                    {
                                        Slave = this.m_SlaveList[i];
                                        if ((Slave != null) && (!Slave.m_boDeath))
                                        {
                                            Slave.RefShowName();
                                        }
                                    }
                                }
                            }
                            n18 = 1;
                        }
                    }
                    else
                    {
                        n18 = -1;
                    }
                }
                else
                {
                    n18 = -1;
                }
            }
        FailExit:
            if (n18 <= 0)
            {
                SendDefMessage(Grobal2.SM_TAKEON_FAIL, n18, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 人物装配装备到身上的装备位置
        /// </summary>
        public void ClientTakeOffItems(byte btWhere, int nItemIdx, string sItemName)
        {
            int n10;
            
            TStdItem StdItem;
            TUserItem UserItem;
            string sUserItemName;
            TBaseObject Slave;
            n10 = 0;
            if (!m_boDealing && (btWhere < 14))
            {
                if (this.m_UseItems[btWhere] != null && this.m_UseItems[btWhere].wIndex > 0)
                {
                    if (this.m_UseItems[btWhere].MakeIndex == nItemIdx)
                    {
                        StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[btWhere].wIndex);
                        if ((StdItem != null) && (new ArrayList(new int[] { 15, 16, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem.StdMode)))
                        {
                            if ((!this.m_boUserUnLockDurg) && (this.m_UseItems[btWhere].btValue[7] != 0))
                            {
                                // '无法取下物品！！！'
                                this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                n10 = -4;
                                goto FailExit;
                            }
                        }
                        // 因为虎啸装备 是吸血成功的几率所以所不能使用 StdItem.Reserved 判断
                        // Shape=193 Need-(30)需等级，Stock-为吸血点 NeedLevel-所需等级 Reserved-成功机率
                        // Shape=193 Need-(31)需攻击，Stock-为吸血点 NeedLevel-所需攻击 Reserved-成功机率
                        // Shape=193 Need-(32)需魔法，Stock-为吸血点 NeedLevel-所需魔法 Reserved-成功机率
                        // Shape=193 Need-(33)需道术，Stock-为吸血点 NeedLevel-所需道术 Reserved-成功机率
                        if (!(StdItem.Shape == 193))
                        {
                            if (!this.m_boUserUnLockDurg && ((StdItem.Reserved & 2) != 0))
                            {
                                // '无法取下物品！！！'
                                this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                n10 = -4;
                                goto FailExit;
                            }
                            if ((StdItem.Reserved & 4) != 0)
                            {
                                // '无法取下物品！！！'
                                this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                n10 = -4;
                                goto FailExit;
                            }
                        }
                        if (M2Share.InDisableTakeOffList(this.m_UseItems[btWhere].wIndex))
                        {
                            // '无法取下物品！！！'
                            this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                            goto FailExit;
                        }
                        // 取自定义物品名称
                        sUserItemName = "";
                        if (this.m_UseItems[btWhere].btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(this.m_UseItems[btWhere].MakeIndex, this.m_UseItems[btWhere].wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(this.m_UseItems[btWhere].wIndex);
                        }
                        if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                        {
                            UserItem = this.m_UseItems[btWhere];
                            if (this.AddItemToBag(UserItem))
                            {
                                this.m_UseItems[btWhere].wIndex = 0;
                                SendAddItem(UserItem);
                                RecalcAbilitys();
                                this.CompareSuitItem(false);// 套装与身上装备对比
                                this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");
                                this.SendMsg(this, Grobal2.RM_SUBABILITY, 0, 0, 0, 0, "");
                                SendDefMessage(Grobal2.SM_TAKEOFF_OK, this.GetFeatureToLong(), this.GetFeatureEx(), 0, 0, "");
                                this.FeatureChanged();
                                if (StdItem.StdMode == 16) // 如果是斗笠则更新名字
                                {
                                    this.RefShowName(); // 宝宝也更新名字
                                    if (this.m_SlaveList.Count > 0)
                                    {
                                        for (var i = 0; i < this.m_SlaveList.Count; i++)
                                        {
                                            Slave = ((this.m_SlaveList[i]) as TBaseObject);
                                            if ((Slave != null) && (!Slave.m_boDeath))
                                            {
                                                Slave.RefShowName();
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                UserItem = null;
                                UserItem = null;
                                n10 = -3;
                            }
                        }
                    }
                }
                else
                {
                    n10 = -2;
                }
            }
            else
            {
                n10 = -1;
            }
        FailExit:
            if (n10 <= 0)
            {
                SendDefMessage(Grobal2.SM_TAKEOFF_FAIL, n10, 0, 0, 0, "");
            }
        }

        private bool ItemDblClick(string sItemName, int nMakeIndex, ref string sMapName, ref int nCurrX, ref int nCurrY)
        {
            bool result;
            TItemEvent ItemEvent;
            result = false;
            sMapName = "";
            nCurrX = -1;
            nCurrY = -1;
            try
            {
                for (int i = M2Share.g_ItemDblClickList.Count - 1; i >= 0; i--)
                {
                    if (M2Share.g_ItemDblClickList.Count <= 0)
                    {
                        break;
                    }
                    ItemEvent = M2Share.g_ItemDblClickList[i];
                    if (ItemEvent.m_nMakeIndex == nMakeIndex)
                    {
                        sMapName = ItemEvent.m_sMapName;
                        nCurrX = ItemEvent.m_nCurrX;
                        nCurrY = ItemEvent.m_nCurrY;
                        M2Share.g_ItemDblClickList.RemoveAt(i);
                        Dispose(ItemEvent);
                        result = true;
                        break;
                    }
                }
                if (!result)
                {
                    ItemEvent = new TItemEvent
                    {
                        m_sItemName = sItemName,
                        m_nMakeIndex = nMakeIndex,
                        m_sMapName = this.m_sMapName,
                        m_nCurrX = this.m_nCurrX,
                        m_nCurrY = this.m_nCurrY
                    };
                    M2Share.g_ItemDblClickList.Add(ItemEvent);
                }
            }
            finally
            {
            }
            M2Share.SaveItemDblClickList();
            return result;
        }

        /// <summary>
        /// 使用物品触发
        /// </summary>
        /// <returns></returns>
        private bool UseStdmodeFunItem(TStdItem StdItem)
        {
            if (M2Share.g_FunctionNPC != null)
            {
                M2Share.g_FunctionNPC.GotoLable(this, "@StdModeFunc" + StdItem.AniCount, false);
                return true;
            }
            return false;
        }

        /// <summary>
        /// 检查包裹是否有指定物品，是否达到指定数 药绳捆使用
        /// </summary>
        /// <returns></returns>
        private bool CheckStdmodeFunItem(TStdItem StdItem)
        {
            bool result = false;
            int nCount = 0;
            TUserItem UserItem;
            TStdItem StdItem1;
            try
            {
                if (this.m_ItemList.Count > 0)
                {
                    for (int i = 0; i < this.m_ItemList.Count; i++)
                    {
                        UserItem = this.m_ItemList[i];
                        if (UserItem != null)
                        {
                            StdItem1 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if (StdItem1 != null)
                            {
                                if ((StdItem1.StdMode == 0) && (StdItem1.Source == StdItem.Source))
                                {
                                    // 是药品，并与捆绳对应
                                    nCount++;
                                    if (nCount >= StdItem.Reserved)
                                    {
                                        result = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.CheckStdmodeFunItem");
            }
            return result;
        }

        public void RecalcAdjusBonus_AdjustAb(ushort Abil, ushort Val, ref ushort lov, ref ushort hiv)
        {
            byte Lo = 0;
            byte Hi = 0;
            
            //Lo = LoByte(Abil);
            //Hi = HiByte(Abil);
            lov = 0;
            hiv = 0;
            for (var i = 1; i <= Val; i++)
            {
                if (Lo + 1 < Hi)
                {
                    Lo++;
                    lov++;
                }
                else
                {
                    Hi++;
                    hiv++;
                }
            }
        }

        // 检查动作状态
        private void RecalcAdjusBonus()
        {
            TNakedAbility BonusTick;
            TNakedAbility NakedAbil;
            int adc;
            int amc;
            int asc;
            int aac;
            int amac;
            ushort ldc = 0;
            ushort lmc = 0;
            ushort lsc = 0;
            ushort lac = 0;
            ushort lmac = 0;
            ushort hdc = 0;
            ushort hmc = 0;
            ushort hsc = 0;
            ushort hac = 0;
            ushort hmac = 0;
            try
            {
                BonusTick = null;
                NakedAbil = null;
                switch (this.m_btJob)
                {
                    case 0:
                        BonusTick = M2Share.g_Config.BonusAbilofWarr;
                        NakedAbil = M2Share.g_Config.NakedAbilofWarr;
                        break;
                    case 1:
                        BonusTick = M2Share.g_Config.BonusAbilofWizard;
                        NakedAbil = M2Share.g_Config.NakedAbilofWizard;
                        break;
                    case 2:
                        BonusTick = M2Share.g_Config.BonusAbilofTaos;
                        NakedAbil = M2Share.g_Config.NakedAbilofTaos;
                        break;
                }
                adc = this.m_BonusAbil.DC / BonusTick.DC;
                amc = this.m_BonusAbil.MC / BonusTick.MC;
                asc = this.m_BonusAbil.SC / BonusTick.SC;
                aac = this.m_BonusAbil.AC / BonusTick.AC;
                amac = this.m_BonusAbil.MAC / BonusTick.MAC;
                RecalcAdjusBonus_AdjustAb(NakedAbil.DC, (ushort)adc, ref ldc, ref hdc);
                RecalcAdjusBonus_AdjustAb(NakedAbil.MC, (ushort)amc, ref lmc, ref hmc);
                RecalcAdjusBonus_AdjustAb(NakedAbil.SC, (ushort)asc, ref lsc, ref hsc);
                RecalcAdjusBonus_AdjustAb(NakedAbil.AC, (ushort)aac, ref lac, ref hac);
                RecalcAdjusBonus_AdjustAb(NakedAbil.MAC, (ushort)amac, ref lmac, ref hmac);
                this.m_WAbil.DC = HUtil32.MakeLong(HUtil32.LoWord(this.m_WAbil.DC) + ldc, HUtil32.HiWord(this.m_WAbil.DC) + hdc);
                this.m_WAbil.MC = HUtil32.MakeLong(HUtil32.LoWord(this.m_WAbil.MC) + lmc, HUtil32.HiWord(this.m_WAbil.MC) + hmc);
                this.m_WAbil.SC = HUtil32.MakeLong(HUtil32.LoWord(this.m_WAbil.SC) + lsc, HUtil32.HiWord(this.m_WAbil.SC) + hsc);
                this.m_WAbil.AC = HUtil32.MakeLong(HUtil32.LoWord(this.m_WAbil.AC) + lac, HUtil32.HiWord(this.m_WAbil.AC) + hac);
                this.m_WAbil.MAC = HUtil32.MakeLong(HUtil32.LoWord(this.m_WAbil.MAC) + lmac, HUtil32.HiWord(this.m_WAbil.MAC) + hmac);
                this.m_WAbil.MaxHP = HUtil32._MIN(Int32.MaxValue, this.m_WAbil.MaxHP + this.m_BonusAbil.HP / BonusTick.HP);// 21亿血
                this.m_WAbil.MaxMP = HUtil32._MIN(Int32.MaxValue, this.m_WAbil.MaxMP + this.m_BonusAbil.MP / BonusTick.MP);
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.RecalcAdjusBonus");
            }
        }

        public int GetMyStatus()
        {
            int result = m_nHungerStatus / 1000;
            if (result > 4)
            {
                result = 4;
            }
            return result;
        }

        private void SendAdjustBonus()
        {
            string sSENDMSG = "";
            this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_ADJUST_BONUS, this.m_nBonusPoint, 0, 0, 0, 0);
            switch (this.m_btJob)
            {
                case 0:
                    sSENDMSG = EncryptUnit.EncodeBuffer(M2Share.g_Config.BonusAbilofWarr) + "/" +
                    EncryptUnit.EncodeBuffer(this.m_BonusAbil) + "/" +
                    EncryptUnit.EncodeBuffer(M2Share.g_Config.NakedAbilofWarr);
                    break;
                case 1:
                    sSENDMSG = EncryptUnit.EncodeBuffer(M2Share.g_Config.BonusAbilofWizard) + "/" +
                        EncryptUnit.EncodeBuffer(this.m_BonusAbil) + "/" +
                        EncryptUnit.EncodeBuffer(M2Share.g_Config.NakedAbilofWizard);
                    break;
                case 2:
                    sSENDMSG = EncryptUnit.EncodeBuffer(M2Share.g_Config.BonusAbilofTaos) + "/"
                        + EncryptUnit.EncodeBuffer(this.m_BonusAbil) + "/"
                        + EncryptUnit.EncodeBuffer(M2Share.g_Config.NakedAbilofWizard);
                    break;
            }
            SendSocket(this.m_DefMsg, sSENDMSG);
        }

        // 鉴定主副将英雄
        public void DelMember(TPlayObject PlayObject)
        {
            if (m_GroupOwner != PlayObject)
            {
                for (int i = m_GroupMembers.Count - 1; i >= 0; i--)
                {
                    if (m_GroupMembers.Count <= 0)
                    {
                        break;
                    }
                    if ((m_GroupMembers[i] != null))
                    {
                        if ((m_GroupMembers[i] == PlayObject))
                        {
                            PlayObject.LeaveGroup();
                            m_GroupMembers.RemoveAt(i);
                            break;
                        }
                    }
                }
            }
            else
            {
                for (int i = m_GroupMembers.Count - 1; i >= 0; i--)
                {
                    if (m_GroupMembers.Count <= 0)
                    {
                        break;
                    }
                    if (m_GroupMembers[i] != null)
                    {
                        m_GroupMembers[i].LeaveGroup();
                        m_GroupMembers.RemoveAt(i);
                    }
                }
            }
            if (!CancelGroup())
            {
                SendDefMessage(Grobal2.SM_GROUPCANCEL, 0, 0, 0, 0, "");
            }
            else
            {
                SendGroupMembers();
            }
        }

        private void ShowMapInfo(string sMAP, string sX, string sY)
        {
            Envirnoment Map;
            int nX = HUtil32.Str_ToInt(sX, 0);
            int nY = HUtil32.Str_ToInt(sY, 0);
            if ((sMAP != "") && (nX >= 0) && (nY >= 0))
            {
                Map = M2Share.g_MapManager.FindMap(sMAP);
                if (Map != null)
                {
                    var success = false;
                    MapCellInfo MapCellInfo = Map.GetMapCellInfo(nX, nY, ref success);
                    if (success)
                    {
                        this.SysMsg("标志: " + MapCellInfo.chFlag, TMsgColor.c_Green, TMsgType.t_Hint);
                        if (MapCellInfo.ObjList != null)
                        {
                            this.SysMsg("对象数: " + MapCellInfo.ObjList.Count, TMsgColor.c_Green, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        this.SysMsg("取地图单元信息失败: " + sMAP, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                }
            }
            else
            {
                this.SysMsg("请按正确格式输入: " + M2Share.g_GameCommand.MAPINFO.sCmd + " 地图号 X Y", TMsgColor.c_Green, TMsgType.t_Hint);
            }
        }

        /// <summary>
        /// 发送组队聊天信息
        /// </summary>
        /// <param name="sMsg"></param>
        private void SendGroupText(string sMsg)
        {
            TPlayObject PlayObject;
            sMsg = M2Share.g_Config.sGroupMsgPreFix + sMsg;
            if (m_GroupOwner != null)
            {
                if (m_GroupOwner.m_GroupMembers.Count > 0)
                {
                    for (int i = 0; i < m_GroupOwner.m_GroupMembers.Count; i++)
                    {
                        PlayObject = m_GroupOwner.m_GroupMembers[i];
                        if (PlayObject == null)
                        {
                            continue;
                        }
                        PlayObject.SendMsg(this, Grobal2.RM_GROUPMESSAGE, 0, M2Share.g_Config.btGroupMsgFColor, M2Share.g_Config.btGroupMsgBColor, 0, sMsg);
                    }
                }
            }
        }

        /// <summary>
        /// PK死亡掉经验、升级、掉钱
        /// 由 TBaseObject.Die调用 
        /// </summary>
        /// <param name="PlayObject"></param>
        public void PKDie(TPlayObject PlayObject)
        {
            int nWinLevel;
            int nLostLevel;
            int nWinExp;
            int nLostExp;
            bool boWinLEvel;
            bool boLostLevel;
            bool boWinExp;
            bool boLostExp;
            nWinLevel = M2Share.g_Config.nKillHumanWinLevel;
            nLostLevel = M2Share.g_Config.nKilledLostLevel;
            nWinExp = M2Share.g_Config.nKillHumanWinExp;
            nLostExp = M2Share.g_Config.nKillHumanLostExp;
            boWinLEvel = M2Share.g_Config.boKillHumanWinLevel;
            boLostLevel = M2Share.g_Config.boKilledLostLevel;
            boWinExp = M2Share.g_Config.boKillHumanWinExp;
            boLostExp = M2Share.g_Config.boKilledLostExp;
            if (this.m_PEnvir.m_boPKWINLEVEL)
            {
                boWinLEvel = true;
                nWinLevel = this.m_PEnvir.m_nPKWINLEVEL;
            }
            if (this.m_PEnvir.m_boPKLOSTLEVEL)
            {
                boLostLevel = true;
                nLostLevel = this.m_PEnvir.m_nPKLOSTLEVEL;
            }
            if (this.m_PEnvir.m_boPKWINEXP)
            {
                boWinExp = true;
                nWinExp = this.m_PEnvir.m_nPKWINEXP;
            }
            if (this.m_PEnvir.m_boPKLOSTEXP)
            {
                boLostExp = true;
                nLostExp = this.m_PEnvir.m_nPKLOSTEXP;
            }
            if (PlayObject.m_Abil.Level - this.m_Abil.Level > M2Share.g_Config.nHumanLevelDiffer)
            {
                if (!PlayObject.IsGoodKilling(this)) // 100
                {
                    PlayObject.IncPkPoint(M2Share.g_Config.nKillHumanAddPKPoint);// '你犯了谋杀罪！！！'
                    PlayObject.SysMsg(GameMsgDef.g_sYouMurderedMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    if (M2Share.g_Config.boUnKnowHum && this.m_LastHiter.IsUsesZhuLi())
                    {
                        //带上斗笠,不显示人的真正名字
                        this.SysMsg(string.Format(GameMsgDef.g_sYouKilledByMsg, "神秘人"), TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    else
                    {
                        this.SysMsg(string.Format(GameMsgDef.g_sYouKilledByMsg, this.m_LastHiter.m_sCharName), TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    PlayObject.AddBodyLuck(-M2Share.g_Config.nKillHumanDecLuckPoint);
                    if (this.PKLevel() < 1)
                    {
                        if (HUtil32.Random(M2Share.g_Config.nKillHumanWeaponUnlockRate) == 0)
                        {
                            PlayObject.MakeWeaponUnlock();
                        }
                    }
                }
                else
                {
                    // '[你受到正当规则保护。]'
                    PlayObject.SysMsg(GameMsgDef.g_sYouProtectedByLawOfDefense, TMsgColor.c_Green, TMsgType.t_Hint);
                }
                return;
            }
            if (boWinLEvel)
            {
                if (PlayObject.m_Abil.Level + nWinLevel <= M2Share.MAXUPLEVEL)
                {
                    PlayObject.m_Abil.Level += (ushort)nWinLevel;// 人物升级记录日志
                    M2Share.AddGameDataLog("12" + "\09" + PlayObject.m_sMapName + "\09" + (PlayObject.m_Abil.Level).ToString()
                        + "\09" + (PlayObject.m_Abil.Exp).ToString() + "/" + (PlayObject.m_Abil.MaxExp).ToString() + "\09" + this.m_sCharName +
                        "\09" + "0" + "\09" + "0" + "\09" + "1" + "\09" + "PK+");
                }
                else
                {
                    PlayObject.m_Abil.Level = M2Share.MAXUPLEVEL;// 人物升级记录日志
                    M2Share.AddGameDataLog("12" + "\09" + PlayObject.m_sMapName + "\09" + (PlayObject.m_Abil.Level).ToString()
                        + "\09" + (PlayObject.m_Abil.Exp).ToString() + "/" + (PlayObject.m_Abil.MaxExp).ToString() + "\09" + this.m_sCharName
                        + "\09" + "0" + "\09" + "0" + "\09" + "1" + "\09" + "PK+");
                }
                PlayObject.HasLevelUp(PlayObject.m_Abil.Level - nWinLevel);
                if (boLostLevel)
                {
                    if (this.PKLevel() >= 2)
                    {
                        if (this.m_Abil.Level >= nLostLevel * 2)
                        {
                            this.m_Abil.Level -= Convert.ToUInt16(nLostLevel * 2);
                        }
                    }
                    else
                    {
                        if (this.m_Abil.Level >= nLostLevel)
                        {
                            this.m_Abil.Level -= (ushort)nLostLevel;
                        }
                    }
                }
            }
            if (boWinExp)
            {
                PlayObject.WinExp(nWinExp);
                if (boLostExp)
                {
                    if (this.m_Abil.Exp >= nLostExp)
                    {
                        if (this.m_Abil.Exp >= nLostExp)
                        {
                            this.m_Abil.Exp -= nLostExp;
                        }
                        else
                        {
                            this.m_Abil.Exp = 0;
                        }
                    }
                    else
                    {
                        if (this.m_Abil.Level >= 1)
                        {
                            this.m_Abil.Level -= 1;
                            this.m_Abil.Exp += this.GetLevelExp(this.m_Abil.Level);
                            if (this.m_Abil.Exp >= nLostExp)
                            {
                                this.m_Abil.Exp -= nLostExp;
                            }
                            else
                            {
                                this.m_Abil.Exp = 0;
                            }
                        }
                        else
                        {
                            this.m_Abil.Level = 0;
                            this.m_Abil.Exp = 0;
                        }
                        HasLevelUp(m_Abil.Level + 1);
                    }
                }
            }
        }

        /// <summary>
        /// 死亡触发函数
        /// </summary>
        /// <returns></returns>
        public bool DieGotoLable()
        {
            bool result = false;
            byte nCode = 0;
            try
            {
                if ((this.m_LastHiter != null) && (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT))
                {
                    nCode = 1;
                    if (this.m_LastHiter.m_Master != null)
                    {
                        if (this.m_LastHiter.m_Master.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                        {
                            nCode = 2;
                            m_sString[0] = ((this.m_LastHiter.m_Master) as TPlayObject).m_sCharName;
                            m_nInteger[0] = ((this.m_LastHiter.m_Master) as TPlayObject).m_WAbil.Level;
                            ((this.m_LastHiter.m_Master) as TPlayObject).m_sString[0] = this.m_sCharName;
                            ((this.m_LastHiter.m_Master) as TPlayObject).m_nInteger[0] = this.m_WAbil.Level;
                            nCode = 3;
                            ((this.m_LastHiter.m_Master) as TPlayObject).KillPlayFunc();
                        }
                        else if (this.m_LastHiter.m_Master.m_btRaceServer == Grobal2.RC_HEROOBJECT)
                        {
                            if (this.m_LastHiter.m_Master.m_Master != null)
                            {
                                nCode = 4;
                                m_sString[0] = ((this.m_LastHiter.m_Master.m_Master) as TPlayObject).m_sCharName;
                                m_nInteger[0] = ((this.m_LastHiter.m_Master.m_Master) as TPlayObject).m_WAbil.Level;
                                ((this.m_LastHiter.m_Master.m_Master) as TPlayObject).m_sString[0] = this.m_sCharName;
                                ((this.m_LastHiter.m_Master.m_Master) as TPlayObject).m_nInteger[0] = this.m_WAbil.Level;
                                nCode = 5;
                                ((this.m_LastHiter.m_Master.m_Master) as TPlayObject).KillPlayFunc();
                            }
                        }
                    }
                    else if (this.m_LastHiter.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                    {
                        nCode = 6;
                        m_sString[0] = ((this.m_LastHiter) as TPlayObject).m_sCharName;
                        m_nInteger[0] = ((this.m_LastHiter) as TPlayObject).m_WAbil.Level;
                        ((this.m_LastHiter) as TPlayObject).m_sString[0] = this.m_sCharName;
                        ((this.m_LastHiter) as TPlayObject).m_nInteger[0] = this.m_WAbil.Level;
                        nCode = 7;
                        ((this.m_LastHiter) as TPlayObject).KillPlayFunc();
                    }
                    if (this.m_LastHiter.m_btRaceServer != Grobal2.RC_PLAYOBJECT)
                    {
                        nCode = 8;
                        m_sString[0] = this.m_LastHiter.m_sCharName;
                        m_nInteger[0] = this.m_LastHiter.m_WAbil.Level;
                    }
                    nCode = 9;
                    result = DieFunc();// 死亡触发
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.DieGotoLable Code:" + nCode);
            }
            return result;
        }

        /// <summary>
        /// 发送组队消息
        /// </summary>
        private void LeaveGroup()
        {
            const string sExitGropMsg = "{0} 已经退出了本组....";
            SendGroupText(string.Format(sExitGropMsg, this.m_sCharName));
            m_GroupOwner = null;
            this.SendMsg(this, Grobal2.RM_GROUPCANCEL, 0, 0, 0, 0, "");
        }

        /// <summary>
        /// 解散队伍
        /// </summary>
        /// <returns></returns>
        private bool CancelGroup()
        {
            const string sCanceGrop = "您的小组被解散了...";
            bool result = true;
            if (m_GroupMembers.Count <= 1)
            {
                SendGroupText(sCanceGrop);
                m_GroupMembers.Clear();
                m_GroupOwner = null;
                result = false;
            }
            return result;
        }

        public void SendGroupMembers()
        {
            TPlayObject PlayObject;
            string sSENDMSG = "";
            if (m_GroupMembers.Count > 0)
            {
                for (int i = 0; i < m_GroupMembers.Count; i++)
                {
                    PlayObject = m_GroupMembers[i];
                    if (PlayObject != null)
                    {
                        sSENDMSG = sSENDMSG + PlayObject.m_sCharName + "/";
                    }
                }
                for (int i = 0; i < m_GroupMembers.Count; i++)
                {
                    PlayObject = m_GroupMembers[i];
                    if (PlayObject != null)
                    {
                        PlayObject.SendDefMessage(Grobal2.SM_GROUPMEMBERS, 0, 0, 0, 0, sSENDMSG);
                    }
                }
            }
        }

        /// <summary>
        /// 根据魔法ID,取魔法数据
        /// </summary>
        /// <param name="nMagicID"></param>
        /// <returns></returns>
        public TUserMagic GetMagicInfo(int nMagicID)
        {
            TUserMagic result = null;
            TUserMagic UserMagic;
            if (nMagicID >= 60 && nMagicID <= 65)
            {
                if (m_MyHero != null)
                {
                    result = ((THeroObject)(m_MyHero)).FindTogetherMagic();
                    return result;
                }
            }
            if (this.m_MagicList.Count > 0)
            {
                for (int i = 0; i < this.m_MagicList.Count; i++)
                {
                    UserMagic = this.m_MagicList[i];
                    if (UserMagic.MagicInfo.wMagicId == nMagicID)
                    {
                        result = UserMagic;
                        break;
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// 根据魔法名称,取魔法数据
        /// </summary>
        /// <param name="sMagicName"></param>
        /// <returns></returns>
        public TUserMagic GetMagicInfo(string sMagicName)
        {
            TUserMagic result = null;
            TUserMagic UserMagic;
            if (this.m_MagicList.Count > 0)
            {
                for (int i = 0; i < this.m_MagicList.Count; i++)
                {
                    UserMagic = this.m_MagicList[i];
                    if (string.Compare(UserMagic.MagicInfo.sMagicName, sMagicName, true) == 0)
                    {
                        result = UserMagic;
                        break;
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// 取技能消耗的MP值
        /// spell-魔法消耗
        /// 修炼等级 / 魔法等级 / 升级魔法
        /// </summary>
        /// <param name="UserMagic"></param>
        /// <returns></returns>
        public int GetSpellPoint(TUserMagic UserMagic)
        {
            return (int)HUtil32.Round((double)UserMagic.MagicInfo.wSpell / (UserMagic.MagicInfo.btTrainLv + 1) * (UserMagic.btLevel + 1)) + UserMagic.MagicInfo.btDefSpell;
        }

        public bool DoMotaebo_CanMotaebo(TBaseObject BaseObject, int nMagicLevel)
        {
            bool result = false;
            if ((this.m_Abil.Level > BaseObject.m_Abil.Level) && (!BaseObject.m_boStickMode))
            {
                int nC = this.m_Abil.Level - BaseObject.m_Abil.Level;
                if (HUtil32.Random(20) < ((nMagicLevel * 4) + 6 + nC))
                {
                    if (this.IsProperTarget(BaseObject))
                    {
                        result = true;
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// 野蛮冲撞
        /// </summary>
        /// <returns></returns>
        private bool DoMotaebo(byte nDir, int nMagicLevel)
        {
            int n20;
            TBaseObject PoseCreate = this.GetPoseCreate();
            TBaseObject BaseObject_30 = null;
            TBaseObject BaseObject_34 = null;
            int nX = 0;
            int nY = 0;
            bool result = false;
            bool bo35 = true;
            this.m_btDirection = nDir;
            int n24 = nMagicLevel + 1;
            int n28 = n24;
            if (PoseCreate != null)
            {
                for (int i = 0; i <= HUtil32._MAX(2, nMagicLevel + 1); i++)
                {
                    PoseCreate = this.GetPoseCreate();
                    if (PoseCreate != null)
                    {
                        n28 = 0;
                        if (!DoMotaebo_CanMotaebo(PoseCreate, nMagicLevel))// 判断对面第一个角色是否可撞
                        {
                            break;
                        }
                        if (nMagicLevel >= 3)// 技能大于3级判断对面第二个角色是否可撞 
                        {
                            if (this.m_PEnvir.GetNextPosition(this.m_nCurrX, this.m_nCurrY, this.m_btDirection, 2, ref nX, ref nY))
                            {
                                BaseObject_30 = this.m_PEnvir.GetMovingObject(nX, nY, true);
                                if ((BaseObject_30 != null) && DoMotaebo_CanMotaebo(BaseObject_30, nMagicLevel))
                                {
                                    BaseObject_30.CharPushed(this.m_btDirection, 1);
                                }
                            }
                        }
                        BaseObject_34 = PoseCreate;
                        if (PoseCreate.CharPushed(this.m_btDirection, 1) != 1)
                        {
                            break;
                        }
                        this.GetFrontPosition(ref nX, ref nY);
                        if (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, nX, nY, false) > 0)
                        {
                            this.m_nCurrX = nX;
                            this.m_nCurrY = nY;
                            this.SendRefMsg(Grobal2.RM_RUSH, nDir, this.m_nCurrX, this.m_nCurrY, 0, "");
                            bo35 = false;
                            result = true;
                        }
                        n24 -= 1;
                    }
                }
            }
            else
            {
                bo35 = false;
                for (int i = 0; i <= HUtil32._MAX(2, nMagicLevel + 1); i++)
                {
                    this.GetFrontPosition(ref nX, ref nY);
                    if (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, nX, nY, false) > 0)
                    {
                        this.m_nCurrX = nX;
                        this.m_nCurrY = nY;
                        this.SendRefMsg(Grobal2.RM_RUSH, nDir, this.m_nCurrX, this.m_nCurrY, 0, "");
                        n28 -= 1;
                    }
                    else
                    {
                        if (this.m_PEnvir.CanWalk(nX, nY, true))
                        {
                            n28 = 0;
                        }
                        else
                        {
                            bo35 = true;
                            break;
                        }
                    }
                }
            }
            if ((BaseObject_34 != null))
            {
                if (n24 < 0)
                {
                    n24 = 0;
                }
                n20 = HUtil32.Random((n24 + 1) * 10) + ((n24 + 1) * 10);
                n20 = BaseObject_34.GetHitStruckDamage(this, n20);
                BaseObject_34.StruckDamage(n20);
                BaseObject_34.SendRefMsg(Grobal2.RM_STRUCK, n20, BaseObject_34.m_WAbil.HP, BaseObject_34.m_WAbil.MaxHP, this.m_ActorsId, "");
                if (BaseObject_34.m_btRaceServer != Grobal2.RC_PLAYOBJECT)
                {
                    BaseObject_34.SendMsg(BaseObject_34, Grobal2.RM_STRUCK, n20, BaseObject_34.m_WAbil.HP, BaseObject_34.m_WAbil.MaxHP, this.m_ActorsId, "");
                }
            }
            if (bo35)
            {
                this.GetFrontPosition(ref nX, ref nY);
                this.SendRefMsg(Grobal2.RM_RUSHKUNG, this.m_btDirection, nX, nY, 0, "");// 冲撞力不够！！！
                this.SysMsg(GameMsgDef.sMateDoTooweak, TMsgColor.c_Red, TMsgType.t_Hint);
            }
            if (n28 > 0)
            {
                if (n24 < 0)
                {
                    n24 = 0;
                }
                n20 = HUtil32.Random(n24 * 10) + ((n24 + 1) * 3);
                n20 = this.GetHitStruckDamage(this, n20);
                this.StruckDamage(n20);
                this.SendRefMsg(Grobal2.RM_STRUCK, n20, this.m_WAbil.HP, this.m_WAbil.MaxHP, 0, "");
            }
            return result;
        }

        public bool DoZXMotaebo_CanMotaebo(TBaseObject BaseObject, int nMagicLevel)
        {
            bool result = false;
            if ((this.m_Abil.Level > BaseObject.m_Abil.Level) && (!BaseObject.m_boStickMode))
            {
                int nC = this.m_Abil.Level - BaseObject.m_Abil.Level;
                if (HUtil32.Random(20) < ((nMagicLevel * 4) + 6 + nC))
                {
                    if (this.IsProperTarget(BaseObject))
                    {
                        result = true;
                    }
                }
            }
            return result;
        }

        // 追心刺 顶5步
        public ushort DoZXMotaebo(byte nDir, int nMagicLevel)
        {
            ushort result;
            bool bo35;
            int n20;
            int n24;
            int n28;
            TBaseObject PoseCreate;
            TBaseObject BaseObject_30;
            TBaseObject BaseObject_34;
            int nX = 0;
            int nY = 0;
            result = 0;
            bo35 = true;
            this.m_btDirection = nDir;
            BaseObject_34 = null;
            n24 = nMagicLevel + 1;
            n28 = n24;
            PoseCreate = this.GetPoseCreate();
            if (PoseCreate != null)
            {
                for (int i = 0; i <= 4; i++)// 推5步
                {
                    PoseCreate = this.GetPoseCreate();
                    if (PoseCreate != null)
                    {
                        n28 = 0;
                        if (!DoZXMotaebo_CanMotaebo(PoseCreate, nMagicLevel))// 判断对面第一个角色是否可撞 
                        {
                            break;
                        }
                        if (nMagicLevel >= 3)// 技能大于3级判断对面第二个角色是否可撞
                        {
                            if (this.m_PEnvir.GetNextPosition(this.m_nCurrX, this.m_nCurrY, this.m_btDirection, 2, ref nX, ref nY))
                            {
                                BaseObject_30 = this.m_PEnvir.GetMovingObject(nX, nY, true);
                                if ((BaseObject_30 != null) && DoZXMotaebo_CanMotaebo(BaseObject_30, nMagicLevel))
                                {
                                    BaseObject_30.CharPushedEx(this.m_btDirection, 1);
                                }
                            }
                        }
                        BaseObject_34 = PoseCreate;
                        if (PoseCreate.CharPushedEx(this.m_btDirection, 1) != 1)
                        {
                            break;
                        }
                        this.GetFrontPosition(ref nX, ref nY);
                        if (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, nX, nY, false) > 0)
                        {
                            this.m_nCurrX = nX;
                            this.m_nCurrY = nY;
                            bo35 = false;
                        }
                        n24 -= 1;
                        result++;
                    }
                }
            }
            else
            {
                bo35 = false;
                for (int i = 0; i <= 4; i++)
                {
                    this.GetFrontPosition(ref nX, ref nY);
                    if (this.m_PEnvir.MoveToMovingObject(this.m_nCurrX, this.m_nCurrY, this, nX, nY, false) > 0)
                    {
                        this.m_nCurrX = nX;
                        this.m_nCurrY = nY;
                        n28 -= 1;
                    }
                    else
                    {
                        if (this.m_PEnvir.CanWalk(nX, nY, true))
                        {
                            n28 = 0;
                        }
                        else
                        {
                            bo35 = true;
                            break;
                        }
                    }
                }
            }

            {
                //HUtil32.ZeroMemory((IntPtr)this.m_nBatterZhuiXin.Defmsg, (IntPtr)sizeof(TDefaultMessage));
                //ZeroMemory(this.m_nBatterZhuiXin.defmsg, sizeof(TDefaultMessage));
                if ((BaseObject_34 != null))
                {
                    this.m_nBatterZhuiXin.Defmsg = new TDefaultMessage();
                    this.m_nBatterZhuiXin.Defmsg.Recog = BaseObject_34.m_ActorsId;
                    this.m_nBatterZhuiXin.Defmsg.Ident = Grobal2.SM_BATTERBACKSTEP;
                    this.m_nBatterZhuiXin.Defmsg.Param = (UInt16)BaseObject_34.m_nCurrX;
                    this.m_nBatterZhuiXin.Defmsg.Tag = (UInt16)BaseObject_34.m_nCurrY;
                    this.m_nBatterZhuiXin.Defmsg.Series = BaseObject_34.m_btDirection;
                    this.m_nBatterZhuiXin.Defmsg.nSessionID = result;
                    this.m_nBatterZhuiXin.desc.feature = BaseObject_34.GetFeature(this);
                    this.m_nBatterZhuiXin.desc.Status = BaseObject_34.m_nCharStatus;
                    this.SendMsg(BaseObject_34, Grobal2.RM_PUSHEX, BaseObject_34.m_btDirection, BaseObject_34.m_nCurrX, BaseObject_34.m_nCurrY, result, "");
                }
            }
            if ((BaseObject_34 != null))
            {
                if (n24 < 0)
                {
                    n24 = 0;
                }
                n20 = HUtil32.Random((n24 + 1) * 10) + ((n24 + 1) * 10);
                n20 = BaseObject_34.GetHitStruckDamage(this, n20);
                BaseObject_34.StruckDamage(n20);
                BaseObject_34.SendRefMsg(Grobal2.RM_STRUCK, n20, BaseObject_34.m_WAbil.HP, BaseObject_34.m_WAbil.MaxHP, this.m_ActorsId, "");
                if (BaseObject_34.m_btRaceServer != Grobal2.RC_PLAYOBJECT)
                {
                    BaseObject_34.SendMsg(BaseObject_34, Grobal2.RM_STRUCK, n20, BaseObject_34.m_WAbil.HP, BaseObject_34.m_WAbil.MaxHP, this.m_ActorsId, "");
                }
            }
            return result;
        }

        /// <summary>
        /// 使用魔法
        /// </summary>
        /// <returns></returns>
        public bool DoSpell(TUserMagic UserMagic, int nTargetX, int nTargetY, TBaseObject BaseObject)
        {
            bool result = false;
            int nSpellPoint;
            try
            {
                if (!M2Share.MagicManager.IsWarrSkill(UserMagic.wMagIdx))
                {
                    nSpellPoint = GetSpellPoint(UserMagic);
                    if ((nSpellPoint > 0) && (UserMagic.wMagIdx != MagicConst.SKILL_68) && (UserMagic.wMagIdx != MagicConst.SKILL_50)
                        && (UserMagic.wMagIdx != MagicConst.SKILL_77) && (UserMagic.wMagIdx != MagicConst.SKILL_78) &&
                        (UserMagic.wMagIdx != MagicConst.SKILL_80) && (UserMagic.wMagIdx != MagicConst.SKILL_81) &&
                        (UserMagic.wMagIdx != MagicConst.SKILL_83) && (UserMagic.wMagIdx != MagicConst.SKILL_84) &&
                        (UserMagic.wMagIdx != MagicConst.SKILL_86) && (UserMagic.wMagIdx != MagicConst.SKILL_87))
                    {
                        // 酒气护体,无极真气不在此处减MP  连击不减MP
                        if (this.m_WAbil.MP < nSpellPoint)
                        {
                            return result;
                        }
                        this.DamageSpell(nSpellPoint);
                        this.HealthSpellChanged();
                    }
                    if (m_boTrainingNG) //学过内功心法,每攻击一次减一点内力值
                    {
                        m_Skill69NH = (ushort)HUtil32._MAX(0, m_Skill69NH - M2Share.g_Config.nHitStruckDecNH);
                        this.SendRefMsg(Grobal2.RM_MAGIC69SKILLNH, 0, m_Skill69NH, m_Skill69MaxNH, 0, "");
                    }
                    result = M2Share.MagicManager.DoSpell(this, UserMagic, nTargetX, nTargetY, BaseObject);
                }
            }
            catch
            {
                M2Share.MainOutMessage(string.Format("[异常] TPlayObject.DoSpell MagID:{0} X:{1} Y:{2}", UserMagic.wMagIdx, nTargetX, nTargetY));
            }
            return result;
        }

        /// <summary>
        /// 挖矿
        /// </summary>
        /// <returns></returns>
        private bool PileStones(int nX, int nY)
        {
            bool result = false;
            string s1C = string.Empty;
            var mineEvent = (TStoneMineEvent)this.m_PEnvir.GetEvent(nX, nY);
            if ((mineEvent != null))
            {
                if ((mineEvent.m_nEventType == M2Share.ET_STONEMINE))
                {
                    if (mineEvent.m_nMineCount > 0)
                    {
                        mineEvent.m_nMineCount -= 1;
                        if (HUtil32.Random(M2Share.g_Config.nMakeMineHitRate) == 0)
                        {
                            var pileEvent = (TPileStones)this.m_PEnvir.GetEvent(this.m_nCurrX, this.m_nCurrY);
                            if (pileEvent == null)
                            {
                                pileEvent = new TPileStones(this.m_PEnvir, this.m_nCurrX, this.m_nCurrY, Grobal2.ET_PILESTONES, 300000); // 5 * 60 * 1000
                                M2Share.g_EventManager.AddEvent(pileEvent);
                            }
                            else
                            {
                                if (pileEvent.m_nEventType == Grobal2.ET_PILESTONES)
                                {
                                    pileEvent.AddEventParam();
                                }
                            }
                            if (HUtil32.Random(M2Share.g_Config.nMakeMineRate) == 0)
                            {
                                MakeMine();
                            }
                            s1C = "1";
                            this.DoDamageWeapon(HUtil32.Random(15) + 5);
                            result = true;
                        }
                    }
                    else
                    {
                        if ((HUtil32.GetTickCount() - mineEvent.m_dwAddStoneMineTick) > 600000)// 10 * 60 * 1000
                        {
                            mineEvent.AddStoneMine();
                        }
                    }
                }
            }
            this.SendRefMsg(Grobal2.RM_HEAVYHIT, this.m_btDirection, this.m_nCurrX, this.m_nCurrY, 0, s1C);
            return result;
        }

        /// <summary>
        /// 发送保存到普通仓库的物品
        /// </summary>
        /// <param name="nBaseObject"></param>
        private unsafe void SendSaveItemList(int nBaseObject)
        {
            TStdItem Item;
            string sSENDMSG = "";
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            TStdItem StdItem = null;
            TUserItem UserItem;
            string sUserItemName;
            if (m_nSoftVersionDateEx == 0)
            {
                if (m_StorageItemList.Count > 0)
                {
                    for (int i = 0; i < m_StorageItemList.Count; i++)
                    {
                        UserItem = m_StorageItemList[i];
                        Item = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                        if (Item != null)
                        {
                            StdItem = Item;
                            M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem);
                            M2Share.CopyStdItemToOStdItem(StdItem, &OClientItem->s);// 取自定义物品名称
                            sUserItemName = "";
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (sUserItemName != "")
                            {
                                HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                                //OClientItem->s->Name = sUserItemName;
                            }
                            OClientItem->Dura = UserItem.Dura;
                            OClientItem->DuraMax = UserItem.DuraMax;
                            OClientItem->MakeIndex = UserItem.MakeIndex;
                            byte[] data = new byte[sizeof(TOClientItem)];
                            fixed (byte* pb = data)
                            {
                                *(TOClientItem*)pb = *OClientItem;
                            }
                            sSENDMSG = sSENDMSG + EncryptUnit.EncodeBuffer(data, sizeof(TOClientItem)) + "/";
                        }
                    }
                }
                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SAVEITEMLIST, nBaseObject, 0, 0, m_StorageItemList.Count, 0);
                SendSocket(this.m_DefMsg, sSENDMSG);
            }
            else
            {
                sSENDMSG = "";
                if (m_StorageItemList.Count > 0)
                {
                    for (int i = 0; i < m_StorageItemList.Count; i++)
                    {
                        UserItem = m_StorageItemList[i];
                        Item = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                        if (Item != null)
                        {
                            StdItem = Item;
                            M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem);
                            ClientItem = new TClientItem
                            {
                                s = StdItem
                            };
                            sUserItemName = ""; // 取自定义物品名称
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (sUserItemName != "")
                            {
                                ClientItem.s.Name = sUserItemName;
                            }
                            if (UserItem.btValue[12] == 1) // 物品发光
                            {
                                ClientItem.s.Reserved1 = 1;
                            }
                            else
                            {
                                ClientItem.s.Reserved1 = 0;
                            }
                            if ((StdItem.StdMode == 60) && (StdItem.Shape != 0))// 酒类,除烧酒外
                            {
                                if (UserItem.btValue[0] != 0)
                                {
                                    ClientItem.s.AC = UserItem.btValue[0]; // 酒的品质
                                }
                                if (UserItem.btValue[1] != 0)
                                {
                                    ClientItem.s.MAC = UserItem.btValue[1];// 酒的酒精度
                                }
                            }
                            if (StdItem.StdMode == 8)// 酿酒材料
                            {
                                if (UserItem.btValue[0] != 0)
                                {
                                    ClientItem.s.AC = UserItem.btValue[0]; // 材料的品质
                                }
                            }
                            ClientItem.Dura = UserItem.Dura;
                            ClientItem.DuraMax = UserItem.DuraMax;
                            ClientItem.MakeIndex = UserItem.MakeIndex;
                            sSENDMSG = sSENDMSG + EncryptUnit.EncodeBuffer<TClientItem>(ClientItem) + "/";
                        }
                    }
                }
                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SAVEITEMLIST, nBaseObject, 0, 0, m_StorageItemList.Count, 0);
                SendSocket(this.m_DefMsg, sSENDMSG);
            }
        }

        // 发送保存到无限仓库的物品
        public int SendSaveBigStorageItemList_GetPageCount(int nListCount)
        {
            int result = 0;
            if (nListCount > 0)
            {
                result = nListCount / 50;
                if ((nListCount % 50) > 0)
                {
                    result++;
                }
            }
            return result;
        }

        /// <summary>
        /// 发送仓库物品
        /// </summary>
        private unsafe void SendSaveBigStorageItemList(int nBaseObject, int nPage)
        {
            TStdItem Item;
            string sSENDMSG;
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            TStdItem StdItem = null;
            string sUserItemName = string.Empty;
            TBigStorage BigStorage = null;
            int nCount;
            int nIndex;
            if (m_nSoftVersionDateEx == 0)
            {
                sSENDMSG = "";
                nCount = 0;
                nIndex = 0;
                if (m_BigStorageItemList != null)
                {
                    if (nPage == 0)
                    {
                        nIndex = 0;
                    }
                    if (nPage > 0)
                    {
                        nIndex = nPage * 50;
                    }
                    if (nIndex > m_BigStorageItemList.Count - 1)
                    {
                        m_nBigStoragePage = SendSaveBigStorageItemList_GetPageCount(m_BigStorageItemList.Count);
                        return;
                    }
                    for (int i = nIndex; i < m_BigStorageItemList.Count; i++)
                    {
                        BigStorage = m_BigStorageItemList[i];
                        Item = M2Share.UserEngine.GetStdItem(BigStorage.UseItems.wIndex);
                        if (Item != null)
                        {
                            nCount++;
                            StdItem = Item;
                            M2Share.ItemUnit.GetItemAddValue(BigStorage.UseItems, StdItem);
                            M2Share.CopyStdItemToOStdItem(StdItem, &OClientItem->s);// 取自定义物品名称
                            sUserItemName = "";
                            if (BigStorage.UseItems.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(BigStorage.UseItems.MakeIndex, BigStorage.UseItems.wIndex);
                            }
                            if (sUserItemName != "")
                            {
                                HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                            }
                            OClientItem->Dura = BigStorage.UseItems.Dura;
                            OClientItem->DuraMax = BigStorage.UseItems.DuraMax;
                            OClientItem->MakeIndex = BigStorage.UseItems.MakeIndex;
                            byte[] data = new byte[sizeof(TOClientItem)];
                            fixed (byte* pb = data)
                            {
                                *(TOClientItem*)pb = *OClientItem;
                            }
                            sSENDMSG = sSENDMSG + EncryptUnit.EncodeBuffer(data, sizeof(TOClientItem)) + "/";
                            if (nCount >= 50)
                            {
                                break;
                            }
                        }
                    }
                }
                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SAVEITEMLIST, nBaseObject, 0, 0, nCount, 0);
                SendSocket(this.m_DefMsg, sSENDMSG);
            }
            else
            {
                sSENDMSG = "";
                nCount = 0;
                nIndex = 0;
                if (m_BigStorageItemList != null)
                {
                    if (nPage == 0)
                    {
                        nIndex = 0;
                    }
                    if (nPage > 0)
                    {
                        nIndex = nPage * 50;
                    }
                    if (nIndex > m_BigStorageItemList.Count - 1)
                    {
                        m_nBigStoragePage = SendSaveBigStorageItemList_GetPageCount(m_BigStorageItemList.Count);
                        return;
                    }
                    for (int i = nIndex; i < m_BigStorageItemList.Count; i++)
                    {
                        BigStorage = m_BigStorageItemList[i];
                        Item = M2Share.UserEngine.GetStdItem(BigStorage.UseItems.wIndex);
                        if (Item != null)
                        {
                            nCount++;
                            StdItem = Item;
                            M2Share.ItemUnit.GetItemAddValue(BigStorage.UseItems, StdItem);
                            ClientItem = new TClientItem
                            {
                                s = StdItem
                            };
                            sUserItemName = ""; // 取自定义物品名称
                            if (BigStorage.UseItems.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(BigStorage.UseItems.MakeIndex, BigStorage.UseItems.wIndex);
                            }
                            if (sUserItemName != "")
                            {
                                ClientItem.s.Name = sUserItemName;
                                //HUtil32.StrToSByteArry(sUserItemName, ClientItem.s.Name, 14, ref ClientItem.s.NameLen);
                            }
                            if (BigStorage.UseItems.btValue[12] == 1)// 物品发光
                            {
                                ClientItem.s.Reserved1 = 1;
                            }
                            else
                            {
                                ClientItem.s.Reserved1 = 0;
                            }
                            if ((StdItem.StdMode == 60) && (StdItem.Shape != 0))// 酒类,除烧酒外
                            {
                                if (BigStorage.UseItems.btValue[0] != 0)
                                {
                                    ClientItem.s.AC = BigStorage.UseItems.btValue[0];  // 酒的品质
                                }
                                if (BigStorage.UseItems.btValue[1] != 0)
                                {
                                    ClientItem.s.MAC = BigStorage.UseItems.btValue[1];// 酒的酒精度
                                }
                            }
                            if (StdItem.StdMode == 8) // 酿酒材料
                            {
                                if (BigStorage.UseItems.btValue[0] != 0)
                                {
                                    ClientItem.s.AC = BigStorage.UseItems.btValue[0];// 材料的品质
                                }
                            }
                            ClientItem.Dura = BigStorage.UseItems.Dura;
                            ClientItem.DuraMax = BigStorage.UseItems.DuraMax;
                            ClientItem.MakeIndex = BigStorage.UseItems.MakeIndex;
                            sSENDMSG = sSENDMSG + EncryptUnit.EncodeBuffer(ClientItem) + "/";
                            if (nCount >= 50)
                            {
                                break;
                            }
                        }
                    }
                }
                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SAVEITEMLIST, nBaseObject, 0, 0, nCount, 0);
                SendSocket(this.m_DefMsg, sSENDMSG);
            }
        }

        // 发送调整的奖金
        private void SendChangeGuildName()
        {
            if (this.m_MyGuild != null)
            {
                SendDefMessage(Grobal2.SM_CHANGEGUILDNAME, 0, 0, 0, 0, this.m_MyGuild.sGuildName + "/" + this.m_sGuildRankName);
            }
            else
            {
                SendDefMessage(Grobal2.SM_CHANGEGUILDNAME, 0, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 发送删除物品列表
        /// </summary>
        /// <param name="ItemList"></param>
        private void SendDelItemList(List<string> ItemList)
        {
            string s10 = "";
            if (ItemList.Count > 0)
            {
                for (int i = 0; i < ItemList.Count; i++)
                {
                    s10 = s10 + ItemList[i] + "/" + ItemList[i] + "/";
                }
            }
            this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_DELITEMS, 0, 0, 0, ItemList.Count, 0);
            SendSocket(this.m_DefMsg, EncryptUnit.EncodeString(s10));
        }

        /// <summary>
        /// 删除物品
        /// </summary>
        /// <param name="UserItem"></param>
        public unsafe virtual void SendDelItems(TUserItem UserItem)
        {
            TStdItem StdItem = null;
            TStdItem StdItem80 = null;
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            string sUserItemName;
            if ((m_nSoftVersionDateEx == 0) && (m_dwClientTick == 0))
            {
                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                if (StdItem != null)
                {
                    StdItem80 = StdItem;
                    M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem80);
                    M2Share.CopyStdItemToOStdItem(StdItem80, &OClientItem->s);// 取自定义物品名称
                    sUserItemName = "";
                    if (UserItem.btValue[13] == 1)
                    {
                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                    }
                    if (sUserItemName != "")
                    {
                        HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                    }
                    OClientItem->MakeIndex = UserItem.MakeIndex;
                    OClientItem->Dura = UserItem.Dura;
                    OClientItem->DuraMax = UserItem.DuraMax;
                    this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_DELITEM, this.m_ActorsId, 0, 0, 1, 0);
                    byte[] data = new byte[sizeof(TOClientItem)];
                    fixed (byte* pb = data)
                    {
                        *(TOClientItem*)pb = *OClientItem;
                    }
                    SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(data, sizeof(TOClientItem)));
                }
            }
            else
            {
                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                if (StdItem != null)
                {
                    StdItem80 = StdItem;
                    M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem80);
                    ClientItem = new TClientItem
                    {
                        s = StdItem80
                    };
                    sUserItemName = "";// 取自定义物品名称
                    if (UserItem.btValue[13] == 1)
                    {
                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                    }
                    if (sUserItemName != "")
                    {
                        ClientItem.s.Name = sUserItemName;
                    }
                    if (UserItem.btValue[12] == 1) // 物品发光
                    {
                        ClientItem.s.Reserved1 = 1;
                    }
                    else
                    {
                        ClientItem.s.Reserved1 = 0;
                    }
                    if ((StdItem.StdMode == 60) && (StdItem.Shape != 0))// 酒类,除烧酒外
                    {
                        if (UserItem.btValue[0] != 0)
                        {
                            ClientItem.s.AC = UserItem.btValue[0];// 酒的品质
                        }
                        if (UserItem.btValue[1] != 0)
                        {
                            ClientItem.s.MAC = UserItem.btValue[1]; // 酒的酒精度
                        }
                    }
                    ClientItem.MakeIndex = UserItem.MakeIndex;
                    ClientItem.Dura = UserItem.Dura;
                    ClientItem.DuraMax = UserItem.DuraMax;
                    this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_DELITEM, this.m_ActorsId, 0, 0, 1, 0);
                    SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer<TClientItem>(ClientItem));
                }
            }
        }

        /// <summary>
        /// 更新物品
        /// </summary>
        /// <param name="UserItem"></param>
        public unsafe void SendUpdateItem(TUserItem UserItem)
        {
            TStdItem StdItem;
            TStdItem StdItem80;
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            string sUserItemName;
            if ((m_nSoftVersionDateEx == 0) && (m_dwClientTick == 0))
            {
                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                if (StdItem != null)
                {
                    StdItem80 = StdItem;
                    M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem80);
                    M2Share.CopyStdItemToOStdItem(StdItem80, &OClientItem->s);// 取自定义物品名称
                    sUserItemName = "";
                    if (UserItem.btValue[13] == 1)
                    {
                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                    }
                    if (sUserItemName != "")
                    {
                        HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                    }
                    OClientItem->MakeIndex = UserItem.MakeIndex;
                    OClientItem->Dura = UserItem.Dura;
                    OClientItem->DuraMax = UserItem.DuraMax;
                    this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_UPDATEITEM, this.m_ActorsId, 0, 0, 1, 0);
                    byte[] data = new byte[sizeof(TOClientItem)];
                    fixed (byte* pb = data)
                    {
                        *(TOClientItem*)pb = *OClientItem;
                    }
                    SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(data, sizeof(TOClientItem)));
                }
            }
            else
            {
                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                if (StdItem != null)
                {
                    StdItem80 = StdItem;
                    M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem80);
                    ClientItem = new TClientItem
                    {
                        s = StdItem80// 取自定义物品名称
                    };
                    sUserItemName = "";
                    if (UserItem.btValue[13] == 1)
                    {
                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                    }
                    if (sUserItemName != "")
                    {
                        ClientItem.s.Name = sUserItemName;
                    }
                    if (UserItem.btValue[12] == 1)// 物品发光
                    {
                        ClientItem.s.Reserved1 = 1;
                    }
                    else
                    {
                        ClientItem.s.Reserved1 = 0;
                    }
                    if ((StdItem.StdMode == 60) && (StdItem.Shape != 0))// 酒类,除烧酒外
                    {
                        if (UserItem.btValue[0] != 0)
                        {
                            ClientItem.s.AC = UserItem.btValue[0]; // 酒的品质
                        }
                        if (UserItem.btValue[1] != 0)
                        {
                            ClientItem.s.MAC = UserItem.btValue[1];// 酒的酒精度
                        }
                    }
                    ClientItem.MakeIndex = UserItem.MakeIndex;
                    ClientItem.Dura = UserItem.Dura;
                    ClientItem.DuraMax = UserItem.DuraMax;
                    this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_UPDATEITEM, this.m_ActorsId, 0, 0, 1, 0);
                    SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(ClientItem));
                }
            }
        }

        /// <summary>
        /// 检查装备是否可以穿上身
        /// </summary>
        /// <returns></returns>
        private bool CheckTakeOnItems(int nWhere, TStdItem StdItem)
        {
            bool result = false;
            TUserCastle Castle;
            if ((StdItem.StdMode == 10) && (this.m_btGender != 0))
            {
                this.SysMsg(GameMsgDef.sWearNotOfWoMan, TMsgColor.c_Red, TMsgType.t_Hint);
                return result;
            }
            if ((StdItem.StdMode == 11) && (this.m_btGender != 1))
            {
                this.SysMsg(GameMsgDef.sWearNotOfMan, TMsgColor.c_Red, TMsgType.t_Hint);
                return result;
            }
            if ((nWhere == 1) || (nWhere == 2))
            {
                if (StdItem.Weight > this.m_WAbil.MaxHandWeight)
                {
                    this.SysMsg(GameMsgDef.sHandWeightNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    return result;
                }
            }
            else
            {
                if ((StdItem.Weight + GetUserItemWeitht(nWhere)) > this.m_WAbil.MaxWearWeight)
                {
                    this.SysMsg(GameMsgDef.sWearWeightNot, TMsgColor.c_Red, TMsgType.t_Hint);// 负重不足
                    return result;
                }
            }
            Castle = M2Share.g_CastleManager.IsCastleMember(this);
            switch (StdItem.Need)
            {
                case 34:
                case 0:// 等级
                    if (this.m_Abil.Level >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 35:
                case 1:// 攻击力
                    if (HUtil32.HiWord(this.m_WAbil.DC) >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sDCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 10:// 职业+等级
                    if ((this.m_btJob == HUtil32.LoWord(StdItem.NeedLevel)) && (this.m_Abil.Level >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sJobOrLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 11:// 职业+攻击力
                    if ((this.m_btJob == HUtil32.LoWord(StdItem.NeedLevel)) && (HUtil32.HiWord(this.m_WAbil.DC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sJobOrDCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 12:// 职业+魔法力
                    if ((this.m_btJob == HUtil32.LoWord(StdItem.NeedLevel)) && (HUtil32.HiWord(this.m_WAbil.MC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sJobOrMCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 13:// 职业+道术
                    if ((this.m_btJob == HUtil32.LoWord(StdItem.NeedLevel)) && (HUtil32.HiWord(this.m_WAbil.SC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sJobOrSCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 18:// Need=18(表示穿戴需等级，装备可提高内力恢复速度) NeedLevel=50(等级条件) Stock=3(提高内力恢复速度)
                    if (this.m_Abil.Level >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 19:// Need=19(表示穿戴需攻击力，装备可提高内力恢复速度%) NeedLevel=50(攻击力条件) Stock=3(提高内力恢复速度%)
                    if ((HUtil32.HiWord(this.m_WAbil.DC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sDCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 20:// Need=20(表示穿戴需魔法，装备可提高内力恢复速度%) NeedLevel=50(魔法条件) Stock=3(提高内力恢复速度%)
                    if ((HUtil32.HiWord(this.m_WAbil.MC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sMCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 21:// Need=21(表示穿戴需道术，装备可提高内力恢复速度%) NeedLevel=50(道术条件) Stock=3(提高内力恢复速度%)
                    if ((HUtil32.HiWord(this.m_WAbil.SC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sSCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 22:// Need=22(表示穿戴需等级，装备可提高内力恢复速度+点) NeedLevel=50(等级条件) Stock=3(每次可提高内力值)
                    if (this.m_Abil.Level >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 23:// Need=23(表示穿戴需攻击力，装备可提高内力恢复速度+点) NeedLevel=50(攻击力条件) Stock=3(每次可提高内力值)
                    if ((HUtil32.HiWord(this.m_WAbil.DC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sDCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 24:// Need=24(表示穿戴需魔法，装备可提高内力恢复速度+点) NeedLevel=50(魔法条件) Stock=3(每次可提高内力值)
                    if ((HUtil32.HiWord(this.m_WAbil.MC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sMCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 25:// Need=25(表示穿戴需道术，装备可提高内力恢复速度+点) NeedLevel=50(道术条件) Stock=3(每次可提高内力值)
                    if ((HUtil32.HiWord(this.m_WAbil.SC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sSCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 26:
                    // ======物品支持防爆属性设置=============//
                    // Need-(26)需等级，Stock-为防爆点 NeedLevel-所需等级
                    if (this.m_Abil.Level >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 27:// Need-(27)需攻击力，Stock-为防爆点 NeedLevel-所需攻击力
                    if ((HUtil32.HiWord(this.m_WAbil.DC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sDCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 28:// Need-(28)需魔法，Stock-为防爆点 NeedLevel-所需魔法
                    if ((HUtil32.HiWord(this.m_WAbil.MC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sMCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 29:// Need-(29)需道术，Stock-为防爆点 NeedLevel-所需道术
                    if ((HUtil32.HiWord(this.m_WAbil.SC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sSCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 30:
                    // ===========穿戴有吸血属性 Need==============//
                    // Need-(30)需等级，Stock-为吸血点 NeedLevel-所需等级  Reserved-成功机率
                    if (this.m_Abil.Level >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 31:// Need-(31)需攻击力，Stock-为吸血点 NeedLevel-所需攻击力  Reserved-成功机率
                    if ((HUtil32.HiWord(this.m_WAbil.DC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sDCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 32:// Need-(32)需魔法，Stock-为吸血点 NeedLevel-所需魔法  Reserved-成功机率
                    if ((HUtil32.HiWord(this.m_WAbil.MC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sMCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 33:// Need-(33)需道术，Stock-为吸血点 NeedLevel-所需道术  Reserved-成功机率
                    if ((HUtil32.HiWord(this.m_WAbil.SC) >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sSCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 36:
                case 2:// 魔法力
                    if (HUtil32.HiWord(this.m_WAbil.MC) >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sMCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 37:
                case 3:// 道术
                    if (HUtil32.HiWord(this.m_WAbil.SC) >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sSCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 4:// 转生等级
                    if (m_btReLevel >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sReNewLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 40:// 转生等级+等级
                    if (m_btReLevel >= HUtil32.LoWord(StdItem.NeedLevel))
                    {
                        if (this.m_Abil.Level >= HUtil32.HiWord(StdItem.NeedLevel))
                        {
                            result = true;
                        }
                        else
                        {
                            this.SysMsg(GameMsgDef.g_sLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sReNewLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 41:// 转生等级+攻击力
                    if (m_btReLevel >= HUtil32.LoWord(StdItem.NeedLevel))
                    {
                        if (HUtil32.HiWord(this.m_WAbil.DC) >= HUtil32.HiWord(StdItem.NeedLevel))
                        {
                            result = true;
                        }
                        else
                        {
                            this.SysMsg(GameMsgDef.g_sDCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sReNewLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 42:// 转生等级+魔法
                    if (m_btReLevel >= HUtil32.LoWord(StdItem.NeedLevel))
                    {
                        if (HUtil32.HiWord(this.m_WAbil.MC) >= HUtil32.HiWord(StdItem.NeedLevel))
                        {
                            result = true;
                        }
                        else
                        {
                            this.SysMsg(GameMsgDef.g_sMCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sReNewLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 43:// 转生等级
                    if (m_btReLevel >= HUtil32.LoWord(StdItem.NeedLevel))
                    {
                        if (HUtil32.HiWord(this.m_WAbil.SC) >= HUtil32.HiWord(StdItem.NeedLevel))
                        {
                            result = true;
                        }
                        else
                        {
                            this.SysMsg(GameMsgDef.g_sSCNot, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sReNewLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 44:// 所需声望和转生等级
                    if (m_btReLevel >= HUtil32.LoWord(StdItem.NeedLevel))
                    {
                        if (m_btCreditPoint >= HUtil32.HiWord(StdItem.NeedLevel))
                        {
                            result = true;
                        }
                        else
                        {
                            this.SysMsg(GameMsgDef.g_sCreditPointNot, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sReNewLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 5:// 所需声望
                    if (m_btCreditPoint >= StdItem.NeedLevel)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sCreditPointNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 6:// 行会物品
                    if ((this.m_MyGuild != null))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sGuildNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 60:// 行会掌门物品
                    if ((this.m_MyGuild != null) && (this.m_nGuildRankNo == 1))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sGuildMasterNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 7:// 沙城成员物品
                    if ((this.m_MyGuild != null) && (Castle != null))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sSabukHumanNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 70:// 沙城城主物品
                    if ((this.m_MyGuild != null) && (Castle != null) && (this.m_nGuildRankNo == 1))
                    {
                        if (this.m_Abil.Level >= StdItem.NeedLevel)
                        {
                            result = true;
                        }
                        else
                        {
                            this.SysMsg(GameMsgDef.g_sLevelNot, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sSabukMasterManNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 8:// 会员物品
                    if (m_nMemberType != 0)
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sMemberNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 81:// 指定类型的会员物品
                    if ((m_nMemberType == HUtil32.LoWord(StdItem.NeedLevel)) && (m_nMemberLevel >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sMemberTypeNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
                case 82:// 指定类型的会员物品
                    if ((m_nMemberType >= HUtil32.LoWord(StdItem.NeedLevel)) && (m_nMemberLevel >= HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = true;
                    }
                    else
                    {
                        this.SysMsg(GameMsgDef.g_sMemberTypeNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    break;
            }
            return result;
        }

        /// <summary>
        /// 取装备物品的重量
        /// </summary>
        /// <returns></returns>
        private int GetUserItemWeitht(int nWhere)
        {
            int result;
            int n14 = 0;
            for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
            {
                if (m_UseItems[i] == null)
                {
                    continue;
                }
                if ((nWhere == -1) || (!(i == nWhere) && !(i == 1) && !(i == 2)))
                {
                    TStdItem StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[i].wIndex);
                    if (StdItem != null)
                    {
                        n14 += StdItem.Weight;
                    }
                }
            }
            result = n14;
            return result;
        }

        /// <summary>
        /// 增加魔法
        /// </summary>
        public void SendAddMagic(TUserMagic UserMagic)
        {
            TClientMagic ClientMagic = new TClientMagic();
            ClientMagic.Key = ((char)UserMagic.btKey);
            ClientMagic.Level = UserMagic.btLevel;
            ClientMagic.CurTrain = UserMagic.nTranPoint;
            ClientMagic.Def = UserMagic.MagicInfo;
            this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_ADDMAGIC, 0, 0, 0, 1, 0);
            SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(ClientMagic));//92
        }

        /// <summary>
        /// 删除魔法
        /// </summary>
        /// <param name="UserMagic"></param>
        public void SendDelMagic(TUserMagic UserMagic)
        {
            this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_DELMAGIC, UserMagic.wMagIdx, 0, 0, 1, 0);
            SendSocket(this.m_DefMsg, "");
        }

        private void ChangeServerMakeSlave(TSlaveInfo SalveInfo)
        {
            int nSlavecount;
            TBaseObject BaseObject;
            if (this.m_btJob == 2)
            {
                nSlavecount = 1;
            }
            else
            {
                nSlavecount = 5;
            }
            BaseObject = this.MakeSlave(SalveInfo.sSalveName, 3, SalveInfo.btSalveLevel, nSlavecount, SalveInfo.dwRoyaltySec);
            if (BaseObject != null)
            {
                BaseObject.n294 = SalveInfo.nKillCount;
                BaseObject.m_btSlaveExpLevel = SalveInfo.btSlaveExpLevel;
                BaseObject.m_WAbil.HP = SalveInfo.nHP;
                BaseObject.m_WAbil.MP = SalveInfo.nMP;
                if ((1500 - SalveInfo.btSalveLevel * 200) < BaseObject.m_nWalkSpeed)
                {
                    BaseObject.m_nWalkSpeed = 1500 - SalveInfo.btSalveLevel * 200;
                }
                if ((2000 - SalveInfo.btSalveLevel * 200) < BaseObject.m_nNextHitTime)
                {
                    BaseObject.m_nWalkSpeed = 2000 - SalveInfo.btSalveLevel * 200;
                }
                RecalcAbilitys();
                this.CompareSuitItem(false);// 套装与身上装备对比
            }
        }

        /// <summary>
        /// 发送删除交易物品栏的物品
        /// </summary>
        private unsafe void SendDelDealItem(TUserItem UserItem)
        {
            TStdItem StdItem;
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            string sUserItemName;
            SendDefMessage(Grobal2.SM_DEALDELITEM_OK, 0, 0, 0, 0, "");
            if (m_DealCreat != null)
            {
                if (m_DealCreat.m_nSoftVersionDateEx == 0)
                {
                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                    if (StdItem != null)
                    {
                        M2Share.CopyStdItemToOStdItem(StdItem, &OClientItem->s);// 取自定义物品名称
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName != "")
                        {
                            HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                        }
                        OClientItem->MakeIndex = UserItem.MakeIndex;
                        OClientItem->Dura = UserItem.Dura;
                        OClientItem->DuraMax = UserItem.DuraMax;
                    }
                    this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_DEALREMOTEDELITEM, this.m_ActorsId, 0, 0, 1, 0);
                    byte[] data = new byte[sizeof(TOClientItem)];
                    fixed (byte* pb = data)
                    {
                        *(TOClientItem*)pb = *OClientItem;
                    }
                    m_DealCreat.SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(data, sizeof(TOClientItem)));
                }
                else
                {
                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                    if (StdItem != null)
                    {
                        ClientItem.s = StdItem;// 取自定义物品名称
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName != "")
                        {
                            ClientItem.s.Name = sUserItemName;
                        }
                        if (UserItem.btValue[12] == 1)// 物品发光
                        {
                            ClientItem.s.Reserved1 = 1;
                        }
                        else
                        {
                            ClientItem.s.Reserved1 = 0;
                        }
                        if ((StdItem.StdMode == 60) && (StdItem.Shape != 0))  // 酒类,除烧酒外
                        {
                            if (UserItem.btValue[0] != 0)
                            {
                                ClientItem.s.AC = UserItem.btValue[0];// 酒的品质
                            }
                            if (UserItem.btValue[1] != 0)
                            {
                                ClientItem.s.MAC = UserItem.btValue[1];// 酒的酒精度
                            }
                        }
                        ClientItem.MakeIndex = UserItem.MakeIndex;
                        ClientItem.Dura = UserItem.Dura;
                        ClientItem.DuraMax = UserItem.DuraMax;
                    }
                    this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_DEALREMOTEDELITEM, this.m_ActorsId, 0, 0, 1, 0);
                    m_DealCreat.SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer<TClientItem>(ClientItem));
                }
                m_DealCreat.m_DealLastTick = HUtil32.GetTickCount();
                m_DealLastTick = HUtil32.GetTickCount();
            }
        }

        /// <summary>
        /// 交易物品
        /// </summary>
        private unsafe void SendAddDealItem(TUserItem UserItem)
        {
            TStdItem StdItem;
            TStdItem StdItem80;
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            string sUserItemName;
            SendDefMessage(Grobal2.SM_DEALADDITEM_OK, 0, 0, 0, 0, "");
            if (m_DealCreat != null)
            {
                if (m_DealCreat.m_nSoftVersionDateEx == 0)
                {
                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                    if (StdItem != null)
                    {
                        StdItem80 = StdItem;// 取自定义物品名称
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName != "")
                        {
                            StdItem80.Name = sUserItemName;
                            //HUtil32.StrToSByteArry(sUserItemName, StdItem80.Name, 14, ref StdItem80.NameLen);
                        }
                        M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem80);
                        M2Share.CopyStdItemToOStdItem(StdItem80, &OClientItem->s);
                        OClientItem->MakeIndex = UserItem.MakeIndex;
                        OClientItem->Dura = UserItem.Dura;
                        OClientItem->DuraMax = UserItem.DuraMax;
                        this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_DEALREMOTEADDITEM, this.m_ActorsId, 0, 0, 1, 0);
                        byte[] data = new byte[sizeof(TOClientItem)];
                        fixed (byte* pb = data)
                        {
                            *(TOClientItem*)pb = *OClientItem;
                        }
                        m_DealCreat.SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(data, sizeof(TOClientItem)));
                        m_DealCreat.m_DealLastTick = HUtil32.GetTickCount();
                        m_DealLastTick = HUtil32.GetTickCount();
                    }
                }
                else
                {
                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                    if (StdItem != null)
                    {
                        StdItem80 = StdItem;
                        M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem80);// 取自定义物品名称
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName != "")
                        {
                            StdItem80.Name = sUserItemName;
                            //HUtil32.StrToSByteArry(sUserItemName, StdItem80.Name, 14, ref StdItem80.NameLen);
                        }
                        if (UserItem.btValue[12] == 1) // 物品发光
                        {
                            StdItem80.Reserved1 = 1;
                        }
                        else
                        {
                            StdItem80.Reserved1 = 0;
                        }
                        if ((StdItem.StdMode == 60) && (StdItem.Shape != 0))// 酒类,除烧酒外 
                        {
                            if (UserItem.btValue[0] != 0)
                            {
                                ClientItem.s.AC = UserItem.btValue[0];// 酒的品质
                            }
                            if (UserItem.btValue[1] != 0)
                            {
                                ClientItem.s.MAC = UserItem.btValue[1];// 酒的酒精度
                            }
                        }
                        ClientItem.s = StdItem80;
                        ClientItem.MakeIndex = UserItem.MakeIndex;
                        ClientItem.Dura = UserItem.Dura;
                        ClientItem.DuraMax = UserItem.DuraMax;
                        this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_DEALREMOTEADDITEM, this.m_ActorsId, 0, 0, 1, 0);
                        m_DealCreat.SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(ClientItem));
                        m_DealCreat.m_DealLastTick = HUtil32.GetTickCount();
                        m_DealLastTick = HUtil32.GetTickCount();
                    }
                }
            }
        }

        /// <summary>
        /// 客户端打开交易界面
        /// </summary>
        private void OpenDealDlg(TPlayObject PlayObject)
        {
            m_boDealing = true;
            m_DealCreat = PlayObject;
            GetBackDealItems();
            SendDefMessage(Grobal2.SM_DEALMENU, 0, 0, 0, 0, m_DealCreat.m_sCharName);
            m_DealLastTick = HUtil32.GetTickCount();
        }

        /// <summary>
        /// 加入小组
        /// </summary>
        public void JoinGroup(TPlayObject PlayObject)
        {
            m_GroupOwner = PlayObject;
            SendGroupText(string.Format(GameMsgDef.g_sJoinGroup, this.m_sCharName));
        }

        /// <summary>
        /// 人物的无极真气  每次使用间隔28秒
        /// 0级提升道术40%(2秒)   1级提升60%(4秒)   2级提升80%(6秒)  3级提升100%(8秒)
        /// </summary>
        /// <returns></returns>
        public bool AbilityUp(TUserMagic UserMagic)
        {
            bool result;
            int nSpellPoint;
            int n14;
            result = false;
            nSpellPoint = GetSpellPoint(UserMagic);
            if (nSpellPoint > 0)
            {
                if ((HUtil32.GetTickCount() - this.m_dwStatusArrTimeOutTick[2] > M2Share.g_Config.nAbilityUpTick * 1000) && (this.m_wStatusArrValue[2] == 0))// 时间间隔
                {
                    if (this.m_WAbil.MP < nSpellPoint)
                    {
                        return result;
                    }
                    this.DamageSpell(nSpellPoint);
                    this.HealthSpellChanged();
                    if (M2Share.g_Config.boAbilityUpFixMode)  // 无极真气使用固定时长模式
                    {
                        n14 = M2Share.g_Config.nAbilityUpFixUseTime;// 无极真气使用固定时长
                    }
                    else
                    {
                        n14 = (UserMagic.btLevel * 2) + 2 + M2Share.g_Config.nAbilityUpUseTime;
                    }
                    this.m_dwStatusArrTimeOutTick[2] = Convert.ToUInt32(HUtil32.GetTickCount() + n14 * 1000);// 使用时间
                    this.m_wStatusArrValue[2] = (ushort)HUtil32.Round(HUtil32.HiWord(this.m_WAbil.SC) * (UserMagic.btLevel * 0.2 + 0.4));// 提升值
                    this.SysMsg("道术瞬时提升" + this.m_wStatusArrValue[2] + "，持续 " + n14 + " 秒", TMsgColor.c_Green, TMsgType.t_Hint);
                    RecalcAbilitys();
                    this.CompareSuitItem(false);// 套装与身上装备对比
                    this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");
                    result = true;
                }
                else
                {
                    this.SysMsg("精神力凝聚失败", TMsgColor.c_Red, TMsgType.t_Hint);
                }
            }
            return result;
        }

        /// <summary>
        /// 随机矿石持久力
        /// </summary>
        /// <returns></returns>
        public int MakeMine_RandomDrua()
        {
            int result = HUtil32.Random(M2Share.g_Config.nStoneGeneralDuraRate) + M2Share.g_Config.nStoneMinDura;
            if (HUtil32.Random(M2Share.g_Config.nStoneAddDuraRate) == 0)
            {
                result = result + HUtil32.Random(M2Share.g_Config.nStoneAddDuraMax);
            }
            return result;
        }

        /// <summary>
        /// 挖矿,给玩家矿石
        /// </summary>
        private void MakeMine()
        {
            TUserItem UserItem = null;
            int nRANDOM;
            if (this.m_ItemList.Count >= Grobal2.MAXBAGITEM)
            {
                return;
            }
            nRANDOM = HUtil32.Random(M2Share.g_Config.nStoneTypeRate);
            if (nRANDOM >= M2Share.g_Config.nGoldStoneMin && nRANDOM <= M2Share.g_Config.nGoldStoneMax)
            {
                UserItem = new TUserItem();
                if (M2Share.UserEngine.CopyToUserItemFromName(M2Share.g_Config.sGoldStone, UserItem))
                {
                    UserItem.Dura = (ushort)MakeMine_RandomDrua();
                    this.m_ItemList.Add(UserItem);
                    this.WeightChanged();
                    SendAddItem(UserItem);
                }
                else
                {
                    UserItem = null;
                }
                return;
            }
            if (nRANDOM >= M2Share.g_Config.nSilverStoneMin && nRANDOM <= M2Share.g_Config.nSilverStoneMax)
            {
                UserItem = new TUserItem();
                if (M2Share.UserEngine.CopyToUserItemFromName(M2Share.g_Config.sSilverStone, UserItem))
                {
                    UserItem.Dura = (ushort)MakeMine_RandomDrua();
                    this.m_ItemList.Add(UserItem);
                    this.WeightChanged();
                    SendAddItem(UserItem);
                }
                else
                {
                    UserItem = null;
                }
                return;
            }
            if (nRANDOM >= M2Share.g_Config.nSteelStoneMin && nRANDOM <= M2Share.g_Config.nSteelStoneMax)
            {
                UserItem = new TUserItem();
                if (M2Share.UserEngine.CopyToUserItemFromName(M2Share.g_Config.sSteelStone, UserItem))
                {
                    UserItem.Dura = (ushort)MakeMine_RandomDrua();
                    this.m_ItemList.Add(UserItem);
                    this.WeightChanged();
                    SendAddItem(UserItem);
                }
                else
                {
                    UserItem = null;
                }
                return;
            }
            if (nRANDOM >= M2Share.g_Config.nBlackStoneMin && nRANDOM <= M2Share.g_Config.nBlackStoneMax)
            {
                UserItem = new TUserItem();
                if (M2Share.UserEngine.CopyToUserItemFromName(M2Share.g_Config.sBlackStone, UserItem))
                {
                    UserItem.Dura = (ushort)MakeMine_RandomDrua();
                    this.m_ItemList.Add(UserItem);
                    this.WeightChanged();
                    SendAddItem(UserItem);
                }
                else
                {
                    UserItem = null;
                }
                return;
            }
            UserItem = new TUserItem();
            if (M2Share.UserEngine.CopyToUserItemFromName(M2Share.g_Config.sCopperStone, UserItem))
            {
                UserItem.Dura = (ushort)MakeMine_RandomDrua();
                this.m_ItemList.Add(UserItem);
                this.WeightChanged();
                SendAddItem(UserItem);
            }
            else
            {
                UserItem = null;
            }
        }

        public TUserItem QuestCheckItem(string sItemName, ref int nCount, ref int nParam, ref int nDura)
        {
            TUserItem result = null;
            TUserItem UserItem = null;
            string s1C;
            nParam = 0;
            nDura = 0;
            nCount = 0;
            if (this.m_ItemList.Count > 0)
            {
                for (int i = 0; i < this.m_ItemList.Count; i++)
                {
                    UserItem = this.m_ItemList[i];
                    s1C = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                    if ((s1C).ToLower().CompareTo((sItemName).ToLower()) == 0)
                    {
                        if (UserItem.Dura > nDura)
                        {
                            nDura = UserItem.Dura;
                            result = UserItem;
                        }
                        nParam += UserItem.Dura;
                        if (result == null)
                        {
                            result = UserItem;
                        }
                        nCount++;
                    }
                }
            }
            return result;
        }

        public bool QuestTakeCheckItem(TUserItem CheckItem)
        {
            bool result = false;
            TUserItem UserItem;
            for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
            {
                if (this.m_ItemList.Count <= 0)
                {
                    break;
                }
                UserItem = this.m_ItemList[i];
                if (UserItem == CheckItem)
                {
                    SendDelItems(UserItem);
                    this.m_ItemList.RemoveAt(i);
                    UserItem = null;
                    UserItem = null;
                    result = true;
                    break;
                }
            }
            for (int i = this.m_UseItems.GetLowerBound(0); i <= this.m_UseItems.GetUpperBound(0); i++)
            {
                if (this.m_UseItems[i] == null) { continue; }
                if (this.m_UseItems[i] == CheckItem)
                {
                    SendDelItems(this.m_UseItems[i]);
                    this.m_UseItems[i].wIndex = 0;
                    result = true;
                    break;
                }
            }
            return result;
        }

        private void ClientQueryRepairCost(int nParam1, int nInt, string sMsg)
        {
            TUserItem UserItem = null;
            TUserItem UserItemA = null;
            TMerchant Merchant = null;
            string sUserItemName;
            if (this.m_ItemList.Count > 0)
            {
                for (int i = 0; i < this.m_ItemList.Count; i++)
                {
                    UserItem = this.m_ItemList[i];
                    if (UserItem == null)
                    {
                        continue;
                    }
                    if ((UserItem.MakeIndex == nInt))
                    {
                        // 取自定义物品名称
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        if (string.Compare(sUserItemName, sMsg, true) == 0)
                        {
                            UserItemA = UserItem;
                            break;
                        }
                    }
                }
            }
            if (UserItemA == null)
            {
                return;
            }
            Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(nParam1);
            if ((Merchant != null) && ((Merchant.m_PEnvir == this.m_PEnvir) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15) && (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)))
            {
                Merchant.ClientQueryRepairCost(this, UserItemA);
            }
        }

        /// <summary>
        /// 客户端修复物品
        /// </summary>
        private void ClientRepairItem(int nParam1, int nInt, string sMsg)
        {
            TUserItem UserItem = null;
            TMerchant Merchant;
            string sUserItemName;
            string sCheckItemName;
            bool bo19 = false;
            if (this.m_ItemList.Count > 0)
            {
                for (int i = 0; i < this.m_ItemList.Count; i++)
                {
                    UserItem = this.m_ItemList[i];
                    if (UserItem.MakeIndex == nInt)
                    {
                        if (this.CheckItemValue(UserItem, 3))
                        {
                            this.SendMsg(this, Grobal2.RM_USERREPAIRITEM_FAIL, 0, 0, 0, 0, "");// 禁止修
                            break;
                        }
                        else
                        {
                            sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                            if (this.PlugOfCheckCanItem(3, sCheckItemName, false, 0, 0))// 禁止物品规则(管理插件功能)
                            {
                                this.SendMsg(this, Grobal2.RM_USERREPAIRITEM_FAIL, 0, 0, 0, 0, "");
                                break;
                            }
                        }
                    }
                    // 取自定义物品名称
                    sUserItemName = "";
                    if (UserItem.btValue[13] == 1)
                    {
                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                    }
                    if (sUserItemName == "")
                    {
                        sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                    }
                    if ((UserItem.MakeIndex == nInt) && ((sUserItemName).ToLower().CompareTo((sMsg).ToLower()) == 0))
                    {
                        bo19 = true;
                        break;
                    }
                }
            }
            if ((UserItem == null) || !bo19)
            {
                return;
            }
            Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(nParam1);
            if ((Merchant != null) && ((Merchant.m_PEnvir == this.m_PEnvir) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15) && (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)))
            {
                Merchant.ClientRepairItem(this, UserItem);
            }
        }

        /// <summary>
        /// 客户端存物品至仓库
        /// </summary>
        private void ClientStorageItem(int NPC, int nItemIdx, string sMsg)
        {
            TMerchant Merchant;
            TUserItem UserItem;
            bool bo19;
            TStdItem StdItem;
            string sUserItemName;
            string sCheckItemName;
            byte nCode;
            nCode = 0;
            m_boCanQueryBag = true;// 出售物品时,不能刷新包裹
            try
            {
                try
                {
                    Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(NPC);
                    nCode = 1;
                    if ((Merchant != null) && (Merchant.m_boBigStorage))
                    {
                        // 无限仓库
                        nCode = 2;
                        bo19 = false;
                        if (sMsg.IndexOf(" ") >= 0)
                        {
                            // 折分物品名称(信件物品的名称后面加了使用次数)
                            HUtil32.GetValidStr3(sMsg, ref sMsg, new string[] { " " });
                        }
                        if ((m_nPayMent == 1) && !M2Share.g_Config.boTryModeUseStorage)
                        {
                            // '试玩模式不可以使用仓库功能！！！'
                            this.SysMsg(GameMsgDef.g_sTryModeCanotUseStorage, TMsgColor.c_Red, TMsgType.t_Hint);
                            SendDefMessage(Grobal2.SM_STORAGE_FAIL, 0, 0, 0, 0, "");
                            return;
                        }
                        nCode = 3;
                        if ((m_BigStorageItemList != null) && (m_BigStorageItemList.Count > M2Share.g_Config.nBigStorageLimitCount))
                        {
                            this.SysMsg(string.Format(GameMsgDef.g_sBigStorageCountIsNul, M2Share.g_Config.nBigStorageLimitCount), TMsgColor.c_Red, TMsgType.t_Hint);
                            SendDefMessage(Grobal2.SM_STORAGE_FAIL, 0, 0, 0, 0, "");
                            return;
                        }
                        nCode = 4;
                        for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                        {
                            if (this.m_ItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = this.m_ItemList[i];
                            if (UserItem.MakeIndex == nItemIdx)
                            {
                                nCode = 5;
                                if (this.CheckItemValue(UserItem, 2))// 禁止存
                                {
                                    break;
                                }
                                else
                                {
                                    nCode = 6;
                                    sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                    if (this.PlugOfCheckCanItem(2, sCheckItemName, false, 0, 0)) // 禁止物品规则(禁止存)
                                    {
                                        break;
                                    }
                                }
                            }
                            nCode = 7;
                            sUserItemName = "";// 取自定义物品名称
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (sUserItemName == "")
                            {
                                sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                            }
                            nCode = 8;
                            if (UserItem.MakeIndex == nItemIdx && string.Compare(sUserItemName, sMsg, true) == 0)
                            {
                                nCode = 9;
                                // 检查NPC是否允许存物品
                                if ((Merchant.m_boBigStorage) && (((Merchant.m_PEnvir == this.m_PEnvir) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15) && (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)) || (Merchant == M2Share.g_FunctionNPC)))
                                {
                                    nCode = 10;
                                    //if (GameMsgDef.g_Storage.Add(ref m_BigStorageItemList, this.m_sCharName, UserItem))
                                    //{
                                    //    nCode = 11;
                                    //    this.m_ItemList.RemoveAt(i);
                                    //    ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex); // 清理包裹和仓库复制物品
                                    //    Dispose(UserItem);
                                    //    this.WeightChanged();
                                    //    SendDefMessage(Grobal2.SM_STORAGE_OK, 0, 0, 0, 0, "");
                                    //    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                    //    nCode = 12;
                                    //    if (StdItem != null)
                                    //    {
                                    //        nCode = 23;
                                    //        if (StdItem.NeedIdentify == 1)
                                    //        {
                                    //            M2Share.AddGameDataLog("1" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + HUtil32.SBytePtrToString(StdItem.Name,0,StdItem.NameLen) + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09" + Merchant.m_sCharName);
                                    //        }
                                    //    }
                                    //}
                                    //else
                                    //{
                                    //    SendDefMessage(Grobal2.SM_STORAGE_FULL, 0, 0, 0, 0, "");
                                    //}
                                    bo19 = true;
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        bo19 = false;
                        nCode = 13;
                        if (sMsg.IndexOf(" ") >= 0)
                        {
                            // 折分物品名称(信件物品的名称后面加了使用次数)
                            HUtil32.GetValidStr3(sMsg, ref sMsg, new string[] { " " });
                        }
                        if ((m_nPayMent == 1) && !M2Share.g_Config.boTryModeUseStorage)
                        {
                            // '试玩模式不可以使用仓库功能！！！'
                            this.SysMsg(GameMsgDef.g_sTryModeCanotUseStorage, TMsgColor.c_Red, TMsgType.t_Hint);
                            return;
                        }
                        nCode = 14;
                        for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                        {
                            if (this.m_ItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = this.m_ItemList[i];
                            nCode = 15;
                            if (UserItem.MakeIndex == nItemIdx)
                            {
                                if (this.CheckItemValue(UserItem, 2)) // 禁止存
                                {
                                    break;
                                }
                                else
                                {
                                    nCode = 16;
                                    sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                    if (this.PlugOfCheckCanItem(2, sCheckItemName, false, 0, 0)) // 禁止物品规则(禁止存)
                                    {
                                        break;
                                    }
                                }
                            }
                            sUserItemName = "";// 取自定义物品名称
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (sUserItemName == "")
                            {
                                sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                            }
                            nCode = 17;
                            if ((UserItem.MakeIndex == nItemIdx) && ((sUserItemName).ToLower().CompareTo((sMsg).ToLower()) == 0))
                            {
                                nCode = 18;
                                Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(NPC);// 检查NPC是否允许存物品
                                if ((Merchant != null) && (Merchant.m_boStorage) && (((Merchant.m_PEnvir == this.m_PEnvir) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15)
                                    && (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)) || (Merchant == M2Share.g_FunctionNPC)))
                                {
                                    nCode = 19;
                                    if (m_StorageItemList.Count < Grobal2.MAXBAGITEM)
                                    {
                                        nCode = 20;
                                        m_StorageItemList.Add(UserItem);
                                        this.m_ItemList.RemoveAt(i);
                                        this.WeightChanged();
                                        SendDefMessage(Grobal2.SM_STORAGE_OK, 0, 0, 0, 0, "");
                                        nCode = 21;
                                        StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        nCode = 22;
                                        if (StdItem.NeedIdentify == 1)
                                        {
                                            M2Share.AddGameDataLog("1" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09"
                                                + this.m_sCharName + "\09" + StdItem.Name + "\09" + (UserItem.MakeIndex).ToString()
                                                + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "("
                                                + HUtil32.LoWord(StdItem.MC) + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/"
                                                + HUtil32.HiWord(StdItem.SC) + ")" + "(" + HUtil32.LoWord(StdItem.AC) + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "("
                                                + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString()
                                                + "/" + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/"
                                                + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/"
                                                + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09"
                                                + Merchant.m_sCharName);
                                        }
                                    }
                                    else
                                    {
                                        SendDefMessage(Grobal2.SM_STORAGE_FULL, 0, 0, 0, 0, "");
                                    }
                                    bo19 = true;
                                }
                                break;
                            }
                        }
                    }
                    if (!bo19)
                    {
                        SendDefMessage(Grobal2.SM_STORAGE_FAIL, 0, 0, 0, 0, "");
                    }
                }
                catch
                {
                    M2Share.MainOutMessage("[异常] TPlayObject.ClientStorageItem  Code:" + nCode);
                }
            }
            finally
            {
                m_boCanQueryBag = false;// 出售物品时,不能刷新包裹
            }
        }

        /// <summary>
        /// 仓库取物品
        /// </summary>
        private void ClientTakeBackStorageItem(int NPC, int nItemIdx, string sMsg)
        {
            TMerchant Merchant;
            
            TUserItem UserItem;
            TUserItem Item;
            bool bo19;
            TStdItem StdItem;
            string sUserItemName;
            if (m_boCanQueryBag)// 使用物品时,不能取出物品
            {
                return;
            }
            Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(NPC);
            if ((Merchant != null) && (Merchant.m_boBigGetBack)) // 无限仓库
            {
                bo19 = false;
                if ((m_nPayMent == 1) && !M2Share.g_Config.boTryModeUseStorage)
                {
                    // '试玩模式不可以使用仓库功能！！！'
                    this.SysMsg(GameMsgDef.g_sTryModeCanotUseStorage, TMsgColor.c_Red, TMsgType.t_Hint);
                    return;
                }
                if (!m_boCanGetBackItem)
                {
                    this.SendMsg(Merchant, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sStorageIsLockedMsg + "\\ \\"
                        + "仓库开锁命令: @" + M2Share.g_GameCommand.UNLOCKSTORAGE.sCmd + "\\" + "仓库加锁命令: @" + M2Share.g_GameCommand.__Lock.sCmd + "\\"
                        + "设置密码命令: @" + M2Share.g_GameCommand.SETPASSWORD.sCmd + "\\" + "修改密码命令: @" + M2Share.g_GameCommand.CHGPASSWORD.sCmd);
                    return;
                }
                //if (M2Share.g_Storage.GetItem(m_BigStorageItemList, sMsg, nItemIdx, ref Item))
                //{
                //    UserItem = new TUserItem();
                //    for (int i = 0; i < 22; i++)
                //    {
                //        UserItem.btValue[i] = 0;
                //    }
                //    UserItem = Item;
                //    if ((this.IsAddWeightAvailable(M2Share.UserEngine.GetStdItemWeight(UserItem.wIndex))))
                //    {
                //        // 检查NPC是否允许取物品
                //        if ((Merchant != null) && (Merchant.m_boBigGetBack) && (((Merchant.m_PEnvir == this.m_PEnvir) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15) && (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)) || (Merchant == M2Share.g_FunctionNPC)))
                //        {
                //            ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);
                //            // 清理包裹和仓库复制物品 20080816
                //            if (this.AddItemToBag(UserItem))
                //            {
                //                SendAddItem(UserItem);
                //                //GameMsgDef.g_Storage.Delete(ref m_BigStorageItemList, sMsg, nItemIdx);
                //                SendDefMessage(Grobal2.SM_TAKEBACKSTORAGEITEM_OK, nItemIdx, 0, 0, 0, "");
                //                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                //                if (StdItem.NeedIdentify == 1)
                //                {
                //                    M2Share.AddGameDataLog("0" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + HUtil32.SBytePtrToString(StdItem.Name, 0, StdItem.NameLen) + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09" + Merchant.m_sCharName);
                //                }
                //            }
                //            else
                //            {
                //                Dispose(UserItem);
                //                SendDefMessage(Grobal2.SM_TAKEBACKSTORAGEITEM_FULLBAG, 0, 0, 0, 0, "");
                //            }
                //            bo19 = true;
                //        }
                //    }
                //    else
                //    {
                //        Dispose(UserItem);
                //        // '无法携带更多的东西！！！'
                //        this.SysMsg(GameMsgDef.g_sCanotGetItems, TMsgColor.c_Red, TMsgType.t_Hint);
                //    }
                //}
            }
            else
            {
                bo19 = false;
                Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(NPC);
                if (Merchant == null)
                {
                    return;
                }
                if ((m_nPayMent == 1) && !M2Share.g_Config.boTryModeUseStorage)
                {
                    // '试玩模式不可以使用仓库功能！！！'
                    this.SysMsg(GameMsgDef.g_sTryModeCanotUseStorage, TMsgColor.c_Red, TMsgType.t_Hint);
                    return;
                }
                if (!m_boCanGetBackItem)
                {
                    this.SendMsg(Merchant, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sStorageIsLockedMsg + "\\ \\" + "仓库开锁命令: @"
                        + M2Share.g_GameCommand.UNLOCKSTORAGE.sCmd + "\\" + "仓库加锁命令: @" + M2Share.g_GameCommand.__Lock.sCmd + "\\" + "设置密码命令: @"
                        + M2Share.g_GameCommand.SETPASSWORD.sCmd + "\\" + "修改密码命令: @" + M2Share.g_GameCommand.CHGPASSWORD.sCmd);
                    return;
                }
                if (m_StorageItemList.Count > 0)
                {
                    for (var i = m_StorageItemList.Count - 1; i >= 0; i--)
                    {
                        UserItem = m_StorageItemList[i];// 取自定义物品名称
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        if ((UserItem.MakeIndex == nItemIdx) && ((sUserItemName).ToLower().CompareTo((sMsg).ToLower()) == 0))
                        {
                            if ((this.IsAddWeightAvailable(M2Share.UserEngine.GetStdItemWeight(UserItem.wIndex))))
                            {
                                // 检查NPC是否允许取物品
                                if ((Merchant != null) && (Merchant.m_boGetback) && (((Merchant.m_PEnvir == this.m_PEnvir) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15) &&
                                    (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)) || (Merchant == M2Share.g_FunctionNPC)))
                                {
                                    ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理包裹和仓库复制物品
                                    if (this.AddItemToBag(UserItem))
                                    {
                                        SendAddItem(UserItem);
                                        m_StorageItemList.RemoveAt(i);
                                        SendDefMessage(Grobal2.SM_TAKEBACKSTORAGEITEM_OK, nItemIdx, 0, 0, 0, "");
                                        StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        if (StdItem.NeedIdentify == 1)
                                        {
                                            M2Share.AddGameDataLog("0" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString()
                                                + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name
                                                + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" +
                                                (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString()
                                                + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString() + "/" +
                                                (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString()
                                                + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" +
                                                (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString()
                                                + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" +
                                                (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/"
                                                + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" +
                                                (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/" +
                                                (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" +
                                                (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" +
                                                (UserItem.btValue[14]).ToString() + "\09" + Merchant.m_sCharName);
                                        }
                                    }
                                    else
                                    {
                                        SendDefMessage(Grobal2.SM_TAKEBACKSTORAGEITEM_FULLBAG, 0, 0, 0, 0, "");
                                    }
                                    bo19 = true;
                                }
                            }
                            else
                            {
                                // '无法携带更多的东西！！！'
                                this.SysMsg(GameMsgDef.g_sCanotGetItems, TMsgColor.c_Red, TMsgType.t_Hint);
                            }
                            break;
                        }
                    }
                }
            }
            if (Merchant == null)
            {
                return;
            }
            if (!bo19)
            {
                SendDefMessage(Grobal2.SM_TAKEBACKSTORAGEITEM_FAIL, 0, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 创建保存人物数据
        /// </summary>
        public unsafe void MakeSaveRcd(ref THumDataInfo HumanRcd)
        {
            THumDataInfo hdi;
            THumData HumData;
            TUserMagic UserMagic;
            HumanRcd = new THumDataInfo();
            HumanRcd.Header.boIsHero = false;
            HumanRcd.Header.btJob = this.m_btJob;
            HumData = HumanRcd.Data;//Size 4487
            HumData.sChrName = this.m_sCharName;
            HumData.sCurMap = this.m_sMapName;
            HumData.wCurX = (ushort)this.m_nCurrX;
            HumData.wCurY = (ushort)this.m_nCurrY;
            HumData.btDir = this.m_btDirection;
            HumData.btHair = this.m_btHair;
            HumData.btSex = this.m_btGender;
            HumData.btJob = this.m_btJob;
            HumData.nGold = this.m_nGold;
            HumData.Abil = new TOAbility();
            HumData.Abil.Level = this.m_Abil.Level;
            HumData.Abil.HP = this.m_Abil.HP;
            HumData.Abil.MP = this.m_Abil.MP;
            HumData.Abil.MaxHP = this.m_Abil.MaxHP;
            HumData.Abil.MaxMP = this.m_Abil.MaxMP;
            HumData.Abil.Exp = this.m_Abil.Exp;
            HumData.Abil.MaxExp = this.m_Abil.MaxExp;
            HumData.Abil.Weight = this.m_Abil.Weight;
            HumData.Abil.MaxWeight = this.m_Abil.MaxWeight;
            HumData.Abil.WearWeight = (byte)this.m_Abil.WearWeight;
            HumData.Abil.MaxWearWeight = (byte)this.m_Abil.MaxWearWeight;
            HumData.Abil.HandWeight = (byte)this.m_Abil.HandWeight;
            HumData.Abil.MaxHandWeight = (byte)this.m_Abil.MaxHandWeight;
            HumData.Abil.NG = this.m_Skill69NH;// 内功当前内力值
            HumData.Abil.MaxNG = this.m_Skill69MaxNH;// 内力值上限
            HumData.n_Reserved = (byte)this.m_Abil.Alcohol;// 酒量
            HumData.n_Reserved1 = (byte)this.m_Abil.MaxAlcohol;// 酒量上限
            HumData.n_Reserved2 = (byte)this.m_Abil.WineDrinkValue;// 醉酒度
            HumData.btUnKnow2 = new byte[3];
            HumData.btUnKnow2[2] = this.n_DrinkWineQuality;// 饮酒时酒的品质
            HumData.UnKnow = new byte[30];
            HumData.UnKnow[4] = n_DrinkWineAlcohol;// 饮酒时酒的度数
            HumData.UnKnow[5] = m_btMagBubbleDefenceLevel;// 魔法盾等级
            HumData.nReserved1 = this.m_Abil.MedicineValue;// 当前药力值
            HumData.nReserved2 = this.m_Abil.MaxMedicineValue;// 药力值上限
            HumData.boReserved3 = this.n_DrinkWineDrunk;// 人是否喝酒醉了
            HumData.nReserved3 = dw_UseMedicineTime;// 使用药酒时间,计算长时间没使用药酒
            HumData.n_Reserved3 = this.n_MedicineLevel; // 药力值等级
            HumData.Exp68 = this.m_Exp68;// 酒气护体当前经验
            HumData.MaxExp68 = this.m_MaxExp68;// 酒气护体升级经验
            HumData.UnKnow[6] = Convert.ToByte(this.m_boTrainingNG);// 是否学习过内功
            if (m_boTrainingNG)// 内功等级
            {
                HumData.UnKnow[7] = this.m_NGLevel;
            }
            else
            {
                HumData.UnKnow[7] = 0;
            }
            HumData.nExpSkill69 = (UInt16)this.m_ExpSkill69;// 内功当前经验
            HumData.Abil.HP = this.m_WAbil.HP;
            HumData.Abil.MP = this.m_WAbil.MP;
            HumData.wStatusTimeArr = this.m_wStatusTimeArr;
            HumData.sHomeMap = this.m_sHomeMap;
            HumData.wHomeX = (ushort)this.m_nHomeX;
            HumData.wHomeY = (ushort)this.m_nHomeY;
            HumData.nPKPOINT = this.m_nPkPoint;
            HumData.BonusAbil = this.m_BonusAbil;
            HumData.nBonusPoint = this.m_nBonusPoint;
            HumData.sStoragePwd = this.m_sStoragePwd;
            HumData.btCreditPoint = this.m_btCreditPoint;
            HumData.btReLevel = this.m_btReLevel;
            HumData.sMasterName = this.m_sMasterName;
            HumData.boMaster = this.m_boMaster;
            HumData.sDearName = this.m_sDearName;
            HumData.nGameGold = this.m_nGameGold;
            HumData.nGameDiaMond = this.m_nGAMEDIAMOND;//金刚石
            HumData.nGameGird = this.m_nGAMEGIRD;//灵符
            HumData.btGameGlory = this.m_btGameGlory;//荣誉
            HumData.nGamePoint = this.m_nGamePoint;
            if (M2Share.g_Config.boSaveExpRate)  // 是否保存双倍经验时间
            {
                HumData.nEXPRATE = Convert.ToUInt16(m_nKillMonExpRate - m_nItmeIncMonExpRate);//经验倍数
                if (HumData.nEXPRATE <= 0)
                {
                    HumData.nEXPRATE = 100;//临时处理用
                }
                HumData.nExpTime = m_dwKillMonExpRateTime;//双倍经验时间
            }
            else
            {
                HumData.nEXPRATE = 100;
                HumData.nExpTime = 0;
            }
            if (m_boAllowGroup)
            {
                HumData.btAllowGroup = 1;
            }
            else
            {
                HumData.btAllowGroup = 0;
            }
            HumData.btF9 = this.btB2;
            HumData.btAttatckMode = this.m_btAttatckMode;
            HumData.btIncHealth = (byte)this.m_nIncHealth;
            HumData.btIncSpell = (byte)this.m_nIncSpell;
            HumData.btIncHealing = (byte)this.m_nIncHealing;
            HumData.btFightZoneDieCount = (byte)this.m_nFightZoneDieCount;
            HumData.sAccount = this.m_sUserID;
            HumData.boLockLogon = this.m_boLockLogon;
            HumData.wContribution = this.m_wContribution;
            HumData.nHungerStatus = this.m_nHungerStatus;
            HumData.boAllowGuildReCall = this.m_boAllowGuildReCall;
            HumData.wGroupRcallTime = (UInt16)this.m_wGroupRcallTime;
            HumData.dBodyLuck = this.m_dBodyLuck;
            HumData.boAllowGroupReCall = this.m_boAllowGroupReCall;
            HumData.btLastOutStatus = this.m_btLastOutStatus;//退出状态 1为死亡退出
            HumData.wMasterCount = this.m_wMasterCount;// 出师徒弟数
            HumData.btUnKnow2[0] = Convert.ToByte(bo_YBDEAL);// 是否开通元宝寄售
            HumData.n_WinExp = (UInt16)this.m_nWinExp;// 聚灵珠  累计经验
            HumData.n_UsesItemTick = (UInt16)this.n_UsesItemTick;// 聚灵珠聚集时间
            HumData.QuestFlag = this.m_QuestFlag;
            HumData.boHasHero = this.m_boHasHero;
            HumData.boReserved1 = this.m_boHasHeroTwo;
            HumData.boIsHero = false;
            HumData.sHeroChrName = m_sHeroCharName;
            HumData.sMentHeroChrName = m_sDeputyHeroCharName;
            HumData.btUnKnow2[1] = this.n_HeroSave;// 是否保存英雄
            HumData.btEF = this.n_myHeroTpye;// 角色身上带的英雄所属的类型 
            HumData.boReserved = this.m_boPlayDrink;// 是否请过酒 T-请过酒
            HumData.m_GiveDate = this.m_GiveGuildFountationDate;// 人物领取行会酒泉日期
            HumData.boReserved2 = this.m_boMakeWine;// 是否酿酒
            HumData.nReserved = this.m_MakeWineTime;// 酿酒的时间,即还有多长时间可以取回酒
            HumData.UnKnow[0] = n_MakeWineItmeType;// 酿酒后,应该可以得到酒的类型
            HumData.UnKnow[1] = n_MakeWineType;// 酿酒的类型 1-普通酒 2-药酒 
            HumData.UnKnow[2] = n_MakeWineQuality;// 酿酒后,应该可以得到酒的品质
            HumData.UnKnow[3] = n_MakeWineAlcohol;// 酿酒后,应该可以得到酒的酒精度
            HumData.m_btFHeroJob = this.m_btDeputyHeroJob;// 副将英雄出战职业
            HumData.HumPulses = new TBatterPulse[4];
            HumData.HumPulses[0] = this.m_HumPulses[0];
            HumData.HumPulses[1] = this.m_HumPulses[1];
            HumData.HumPulses[2] = this.m_HumPulses[2];
            HumData.HumPulses[3] = this.m_HumPulses[3];
            HumData.BatterMagicOrder = new ushort[3];
            HumData.BatterMagicOrder[0] = this.m_nBatterOrder[0];// 连击技能循序
            HumData.BatterMagicOrder[1] = this.m_nBatterOrder[1];// 连击技能循序
            HumData.BatterMagicOrder[2] = this.m_nBatterOrder[2];// 连击技能循序
            HumanRcd.Data.HumItems = new TUserItem[9];
            HumanRcd.Data.HumItems[Grobal2.U_DRESS] = this.m_UseItems[Grobal2.U_DRESS];
            HumanRcd.Data.HumItems[Grobal2.U_WEAPON] = this.m_UseItems[Grobal2.U_WEAPON];
            HumanRcd.Data.HumItems[Grobal2.U_RIGHTHAND] = this.m_UseItems[Grobal2.U_RIGHTHAND];
            HumanRcd.Data.HumItems[Grobal2.U_HELMET] = this.m_UseItems[Grobal2.U_NECKLACE];
            HumanRcd.Data.HumItems[Grobal2.U_NECKLACE] = this.m_UseItems[Grobal2.U_HELMET];
            HumanRcd.Data.HumItems[Grobal2.U_ARMRINGL] = this.m_UseItems[Grobal2.U_ARMRINGL];
            HumanRcd.Data.HumItems[Grobal2.U_ARMRINGR] = this.m_UseItems[Grobal2.U_ARMRINGR];
            HumanRcd.Data.HumItems[Grobal2.U_RINGL] = this.m_UseItems[Grobal2.U_RINGL];
            HumanRcd.Data.HumItems[Grobal2.U_RINGR] = this.m_UseItems[Grobal2.U_RINGR];
            HumanRcd.Data.HumAddItems = new TUserItem[5];
            HumanRcd.Data.HumAddItems[0] = this.m_UseItems[0];
            HumanRcd.Data.HumAddItems[1] = this.m_UseItems[1];
            HumanRcd.Data.HumAddItems[2] = this.m_UseItems[2];
            HumanRcd.Data.HumAddItems[3] = this.m_UseItems[3];
            HumanRcd.Data.HumAddItems[4] = this.m_UseItems[4];//斗笠
            HumanRcd.Data.BagItems = new TUserItem[46];
            if (this.m_ItemList.Count > 0)
            {
                for (int i = 0; i < this.m_ItemList.Count; i++)
                {
                    if (i >= Grobal2.MAXBAGITEM)
                    {
                        break;
                    }
                    TUserItem item = this.m_ItemList[i];
                    if (item != null)
                    {
                        if (item.wIndex == 0)  //ID为0的物品则不保存
                        {
                            continue;
                        }
                        HumanRcd.Data.BagItems[i] = item;
                    }
                }
            }
            for (int i = 0; i < HumanRcd.Data.BagItems.Length; i++)
            {
                TUserItem item = HumanRcd.Data.BagItems[i];
                if (item == null)
                {
                    HumanRcd.Data.BagItems[i] = new TUserItem();
                }
            }
            HumanRcd.Data.HumMagics = new THumMagic[30];
            HumanRcd.Data.HumBatterMagics = new THumMagic[4];
            HumanRcd.Data.HumNGMagics = new THumMagic[30];
            if (this.m_MagicList.Count > 0)
            {
                int J = 0;
                int K = 0;
                int B = 0;
                for (int i = 0; i < this.m_MagicList.Count; i++)
                {
                    UserMagic = this.m_MagicList[i];
                    if ((UserMagic.MagicInfo.sDescr != "内功"))
                    {
                        if (UserMagic.MagicInfo.sDescr != "连击")
                        {
                            if (J >= M2Share.MAXMAGIC)
                            {
                                continue;
                            }
                            HumanRcd.Data.HumMagics[J] = new THumMagic();
                            HumanRcd.Data.HumMagics[J].wMagIdx = UserMagic.wMagIdx;
                            HumanRcd.Data.HumMagics[J].btLevel = UserMagic.btLevel;
                            HumanRcd.Data.HumMagics[J].btKey = UserMagic.btKey;
                            HumanRcd.Data.HumMagics[J].nTranPoint = UserMagic.nTranPoint;
                            J++;
                        }
                        else
                        {
                            if (B >= 4)
                            {
                                continue;
                            }
                            HumanRcd.Data.HumBatterMagics[B] = new THumMagic();
                            HumanRcd.Data.HumBatterMagics[B].wMagIdx = UserMagic.wMagIdx;
                            HumanRcd.Data.HumBatterMagics[B].btLevel = UserMagic.btLevel;
                            HumanRcd.Data.HumBatterMagics[B].btKey = UserMagic.btKey;
                            HumanRcd.Data.HumBatterMagics[B].nTranPoint = UserMagic.nTranPoint;
                            B++;
                        }
                    }
                    else
                    {
                        if (K >= M2Share.MAXMAGIC)
                        {
                            continue;
                        }
                        HumanRcd.Data.HumNGMagics[K] = new THumMagic();
                        HumanRcd.Data.HumNGMagics[K].wMagIdx = UserMagic.wMagIdx;
                        HumanRcd.Data.HumNGMagics[K].btLevel = UserMagic.btLevel;
                        HumanRcd.Data.HumNGMagics[K].btKey = UserMagic.btKey;
                        HumanRcd.Data.HumNGMagics[K].nTranPoint = UserMagic.nTranPoint;
                        K++;
                    }
                }
            }
            for (int i = 0; i < HumanRcd.Data.HumMagics.Length; i++)
            {
                if (HumanRcd.Data.HumMagics[i] == null)
                {
                    HumanRcd.Data.HumMagics[i] = new THumMagic();
                }
            }
            for (int i = 0; i < HumanRcd.Data.HumNGMagics.Length; i++)
            {
                if (HumanRcd.Data.HumNGMagics[i] == null)
                {
                    HumanRcd.Data.HumNGMagics[i] = new THumMagic();
                }
            }
            for (int i = 0; i < HumanRcd.Data.HumBatterMagics.Length; i++)
            {
                if (HumanRcd.Data.HumBatterMagics[i] == null)
                {
                    HumanRcd.Data.HumBatterMagics[i] = new THumMagic();
                }
            }
            HumanRcd.Data.StorageItems = new TUserItem[46];
            if (m_StorageItemList.Count > 0)
            {
                for (int i = 0; i < m_StorageItemList.Count; i++)
                {
                    if (i >= Grobal2.MAXBAGITEM)
                    {
                        break;
                    }
                    TUserItem item = this.m_ItemList[i];
                    if (item != null)
                    {
                        if (item.wIndex == 0)  //ID为0的物品则不保存
                        {
                            continue;
                        }
                        HumanRcd.Data.StorageItems[i] = item;
                    }
                }
            }
            for (int i = 0; i < HumanRcd.Data.StorageItems.Length; i++)
            {
                TUserItem item = HumanRcd.Data.StorageItems[i];
                if (item == null)
                {
                    HumanRcd.Data.StorageItems[i] = new TUserItem();
                }
            }
        }

        /// <summary>
        /// 刷新人物封号
        /// </summary>
        public void RefRankInfo(int nRankNo, string sRankName)
        {
            this.m_nGuildRankNo = nRankNo;
            this.m_sGuildRankName = sRankName;
            this.SendMsg(this, Grobal2.RM_CHANGEGUILDNAME, 0, 0, 0, 0, "");
        }

        /// <summary>
        /// 获取旧版角色属性
        /// </summary>
        private void GetOldAbil(TOAbility OAbility)
        {
            OAbility.Level = this.m_WAbil.Level;
            OAbility.AC = HUtil32.MakeWord((byte)HUtil32._MIN(Byte.MaxValue, HUtil32.LoWord(this.m_WAbil.AC)), (byte)HUtil32._MIN(Byte.MaxValue, HUtil32.HiWord(this.m_WAbil.AC)));
            OAbility.MAC = HUtil32.MakeWord((byte)HUtil32._MIN(Byte.MaxValue, HUtil32.LoWord(this.m_WAbil.MAC)), (byte)HUtil32._MIN(Byte.MaxValue, HUtil32.HiWord(this.m_WAbil.MAC)));
            OAbility.DC = HUtil32.MakeWord((byte)HUtil32._MIN(Byte.MaxValue, HUtil32.LoWord(this.m_WAbil.DC)), (byte)HUtil32._MIN(Byte.MaxValue, HUtil32.HiWord(this.m_WAbil.DC)));
            OAbility.MC = HUtil32.MakeWord((byte)HUtil32._MIN(Byte.MaxValue, HUtil32.LoWord(this.m_WAbil.MC)), (byte)HUtil32._MIN(Byte.MaxValue, HUtil32.HiWord(this.m_WAbil.MC)));
            OAbility.SC = HUtil32.MakeWord((byte)HUtil32._MIN(Byte.MaxValue, HUtil32.LoWord(this.m_WAbil.SC)), (byte)HUtil32._MIN(Byte.MaxValue, HUtil32.HiWord(this.m_WAbil.SC)));
            OAbility.HP = this.m_WAbil.HP;
            OAbility.MP = this.m_WAbil.MP;
            OAbility.MaxHP = this.m_WAbil.MaxHP;
            OAbility.MaxMP = this.m_WAbil.MaxMP;
            OAbility.Exp = this.m_WAbil.Exp;
            OAbility.MaxExp = this.m_WAbil.MaxExp;
            OAbility.Weight = this.m_WAbil.Weight;
            OAbility.MaxWeight = this.m_WAbil.MaxWeight;
            OAbility.WearWeight = (byte)HUtil32._MIN(Byte.MaxValue, this.m_WAbil.WearWeight);
            OAbility.MaxWearWeight = (byte)HUtil32._MIN(Byte.MaxValue, this.m_WAbil.MaxWearWeight);
            OAbility.HandWeight = (byte)HUtil32._MIN(Byte.MaxValue, this.m_WAbil.HandWeight);
            OAbility.MaxHandWeight = (byte)HUtil32._MIN(Byte.MaxValue, this.m_WAbil.MaxHandWeight);
        }

        /// <summary>
        /// 获取攻击消息数量
        /// </summary>
        /// <returns></returns>
        public unsafe int GetHitMsgCount()
        {
            int result = 0;
            TSendMessage* SendMessage = null;
            try
            {
                HUtil32.EnterCriticalSection(M2Share.ProcessMsgCriticalSection);
                if (this.m_MsgList.Count > 0)
                {
                    for (int i = 0; i < this.m_MsgList.Count; i++)
                    {
                        SendMessage = (TSendMessage*)this.m_MsgList[i];// 逐日剑法  烈火 4级烈火 四级刺杀 圆月弯刀
                        if ((SendMessage->wIdent == Grobal2.CM_HIT) || (SendMessage->wIdent == Grobal2.CM_HEAVYHIT) ||
                            (SendMessage->wIdent == Grobal2.CM_BIGHIT) || (SendMessage->wIdent == Grobal2.CM_POWERHIT) ||
                            (SendMessage->wIdent == Grobal2.CM_LONGHIT) || (SendMessage->wIdent == Grobal2.CM_WIDEHIT) ||
                            (SendMessage->wIdent == Grobal2.CM_CRSHIT) || (SendMessage->wIdent == Grobal2.CM_DAILY) ||
                            (SendMessage->wIdent == Grobal2.CM_FIREHIT) || (SendMessage->wIdent == Grobal2.CM_4FIREHIT) ||
                            (SendMessage->wIdent == Grobal2.CM_4LONGHIT) || (SendMessage->wIdent == Grobal2.CM_YUANYUEHIT))
                        {
                            result++;
                        }
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.ProcessMsgCriticalSection);
            }
            return result;
        }

        /// <summary>
        /// 取攻击消息数量
        /// </summary>
        /// <returns></returns>
        public unsafe int GetSpellMsgCount()
        {
            int result = 0;
            TSendMessage* SendMessage = null;
            try
            {
                HUtil32.EnterCriticalSection(M2Share.ProcessMsgCriticalSection);
                if (this.m_MsgList.Count > 0)
                {
                    for (int i = 0; i < this.m_MsgList.Count; i++)
                    {
                        SendMessage = (TSendMessage*)this.m_MsgList[i];
                        if ((SendMessage->wIdent == Grobal2.CM_SPELL))
                        {
                            result++;
                        }
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.ProcessMsgCriticalSection);
            }
            return result;
        }

        public unsafe int GetRunMsgCount()
        {
            int result = 0;
            TSendMessage* SendMessage = null;
            try
            {
                HUtil32.EnterCriticalSection(M2Share.ProcessMsgCriticalSection);
                if (this.m_MsgList.Count > 0)
                {
                    for (int i = 0; i < this.m_MsgList.Count; i++)
                    {
                        SendMessage = (TSendMessage*)this.m_MsgList[i];
                        if ((SendMessage->wIdent == Grobal2.CM_RUN))
                        {
                            result++;
                        }
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.ProcessMsgCriticalSection);
            }
            return result;
        }

        public unsafe int GetWalkMsgCount()
        {
            int result;
            TSendMessage* SendMessage = null;
            result = 0;
            try
            {
                HUtil32.EnterCriticalSection(M2Share.ProcessMsgCriticalSection);
                if (this.m_MsgList.Count > 0)
                {
                    for (int i = 0; i < this.m_MsgList.Count; i++)
                    {
                        SendMessage = (TSendMessage*)this.m_MsgList[i];
                        if ((SendMessage->wIdent == Grobal2.CM_WALK))
                        {
                            result++;
                        }
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.ProcessMsgCriticalSection);
            }
            return result;
        }

        public unsafe int GetTurnMsgCount()
        {
            int result = 0;
            TSendMessage* SendMessage = null;
            try
            {
                HUtil32.EnterCriticalSection(M2Share.ProcessMsgCriticalSection);
                if (this.m_MsgList.Count > 0)
                {
                    for (int i = 0; i < this.m_MsgList.Count; i++)
                    {
                        SendMessage = (TSendMessage*)this.m_MsgList[i];
                        if ((SendMessage->wIdent == Grobal2.CM_TURN))
                        {
                            result++;
                        }
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.ProcessMsgCriticalSection);
            }
            return result;
        }

        public unsafe int GetSiteDownMsgCount()
        {
            int result;
            TSendMessage* SendMessage = null;
            result = 0;
            HUtil32.EnterCriticalSection(M2Share.ProcessMsgCriticalSection);
            try
            {
                if (this.m_MsgList.Count > 0)
                {
                    for (int i = 0; i < this.m_MsgList.Count; i++)
                    {
                        SendMessage = (TSendMessage*)this.m_MsgList[i];
                        if ((SendMessage->wIdent == Grobal2.CM_SITDOWN))
                        {
                            result++;
                        }
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.ProcessMsgCriticalSection);
            }
            return result;
        }

        /// <summary>
        /// 检查角色当前动作状态
        /// </summary>
        /// <param name="wIdent"></param>
        /// <param name="dwDelayTime"></param>
        /// <returns></returns>
        private bool CheckActionStatus(int wIdent, ref uint dwDelayTime)
        {
            bool result = false;
            uint dwCheckTime;
            uint dwActionIntervalTime;
            dwDelayTime = 0;// 检查人物弯腰停留时间
            if (!M2Share.g_Config.boDisableStruck)
            {
                dwCheckTime = HUtil32.GetTickCount() - this.m_dwStruckTick;
                if (M2Share.g_Config.dwStruckTime > dwCheckTime)
                {
                    dwDelayTime = M2Share.g_Config.dwStruckTime - dwCheckTime;
                    m_btOldDir = this.m_btDirection;
                    return result;
                }
            }
            // 检查二个不同操作之间所需间隔时间
            dwCheckTime = HUtil32.GetTickCount() - m_dwActionTick;
            if (m_boTestSpeedMode)
            {
                this.SysMsg("间隔: " + dwCheckTime, TMsgColor.c_Blue, TMsgType.t_Notice);
            }
            if (m_wOldIdent == wIdent)// 当二次操作一样时，则将 boFirst 设置为 真 ，退出由调用函数本身检查二个相同操作之间的间隔时间
            {
                result = true;
                return result;
            }
            if (!M2Share.g_Config.boControlActionInterval)
            {
                result = true;
                return result;
            }
            dwActionIntervalTime = m_dwActionIntervalTime;
            switch (wIdent)
            {
                case Grobal2.CM_LONGHIT:// 跑位刺杀
                    if (M2Share.g_Config.boControlRunLongHit && (m_wOldIdent == Grobal2.CM_RUN) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwRunLongHitIntervalTime;
                    }
                    break;
                case Grobal2.CM_HIT:// 走位攻击
                    if (M2Share.g_Config.boControlWalkHit && (m_wOldIdent == Grobal2.CM_WALK) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwWalkHitIntervalTime;
                    }
                    // 跑位攻击
                    if (M2Share.g_Config.boControlRunHit && (m_wOldIdent == Grobal2.CM_RUN) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwRunHitIntervalTime;
                    }
                    break;
                case Grobal2.CM_RUN:// 跑位刺杀
                    if (M2Share.g_Config.boControlRunLongHit && (m_wOldIdent == Grobal2.CM_LONGHIT) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwRunLongHitIntervalTime;
                    }
                    // 跑位攻击
                    if (M2Share.g_Config.boControlRunHit && (m_wOldIdent == Grobal2.CM_HIT) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwRunHitIntervalTime;
                    }
                    // 跑位魔法
                    if (M2Share.g_Config.boControlRunMagic && (m_wOldIdent == Grobal2.CM_SPELL) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwRunMagicIntervalTime;
                    }
                    break;
                case Grobal2.CM_WALK:// 走位攻击
                    if (M2Share.g_Config.boControlWalkHit && (m_wOldIdent == Grobal2.CM_HIT) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwWalkHitIntervalTime;
                    }
                    // 跑位刺杀
                    if (M2Share.g_Config.boControlRunLongHit && (m_wOldIdent == Grobal2.CM_LONGHIT) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwRunLongHitIntervalTime;
                    }
                    break;
                case Grobal2.CM_SPELL:// 跑位魔法
                    if (M2Share.g_Config.boControlRunMagic && (m_wOldIdent == Grobal2.CM_RUN) && (m_btOldDir != this.m_btDirection))
                    {
                        dwActionIntervalTime = m_dwRunMagicIntervalTime;
                    }
                    break;
            }
            // 将几个攻击操作合并成一个攻击操作代码 逐日剑法 烈火 4级烈火 四级刺杀 圆月弯刀
            if ((wIdent == Grobal2.CM_HIT) || (wIdent == Grobal2.CM_HEAVYHIT) || (wIdent == Grobal2.CM_BIGHIT)
                || (wIdent == Grobal2.CM_POWERHIT) || (wIdent == Grobal2.CM_WIDEHIT) || (wIdent == Grobal2.CM_CRSHIT)
                || (wIdent == Grobal2.CM_DAILY) || (wIdent == Grobal2.CM_FIREHIT) || (wIdent == Grobal2.CM_4FIREHIT) || (wIdent == Grobal2.CM_4LONGHIT) || (wIdent == Grobal2.CM_YUANYUEHIT))
            {
                wIdent = Grobal2.CM_HIT;
            }
            if (dwCheckTime >= dwActionIntervalTime)
            {
                m_dwActionTick = HUtil32.GetTickCount();
                result = true;
            }
            else
            {
                dwDelayTime = dwActionIntervalTime - dwCheckTime;
            }
            m_wOldIdent = (ushort)wIdent;
            m_btOldDir = this.m_btDirection;
            return result;
        }

        /// <summary>
        /// 添加脚本标签到列表
        /// </summary>
        /// <param name="sLabel"></param>
        public void SetScriptLabel(string sLabel)
        {
            m_CanJmpScriptLableList.Clear();
            m_CanJmpScriptLableList.Add(sLabel);
        }

        /// <summary>
        /// 取得当前脚本可以跳转的标签
        /// </summary>
        /// <param name="sMsg"></param>
        public void GetScriptLabel(string sMsg)
        {
            string sText = string.Empty;
            string sData = string.Empty;
            string sCmdStr = string.Empty;
            string sLabel = string.Empty;
            try
            {
                m_CanJmpScriptLableList.Clear();
                while (true)
                {
                    if (sMsg == "")
                    {
                        break;
                    }
                    sMsg = HUtil32.GetValidStr3(sMsg, ref sText, new string[] { "\\" });
                    if (sText != "")
                    {
                        sData = "";
                        while ((sText.IndexOf("<") > -1) && (sText.IndexOf(">") > -1) && (sText != ""))
                        {
                            if (sText[0] != '<')
                            {
                                sText = "<" + HUtil32.GetValidStr3(sText, ref sData, new string[] { "<" });
                            }
                            sText = HUtil32.ArrestStringEx(sText, "<", ">", ref sCmdStr);
                            sLabel = HUtil32.GetValidStr3(sCmdStr, ref sCmdStr, new string[] { "/" });
                            if (sLabel != "")
                            {
                                m_CanJmpScriptLableList.Add(sLabel);
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.GetScriptLabel");
            }
        }

        /// <summary>
        /// 检查标签是否存在可以跳转的列表中
        /// </summary>
        /// <param name="sLabel"></param>
        /// <returns></returns>
        public bool LableIsCanJmp(string sLabel)
        {
            bool result = false;
            if (string.Compare(sLabel, "@main", true) == 0)
            {
                result = true;
                return result;
            }
            if (m_CanJmpScriptLableList.Count > 0)
            {
                foreach (string item in m_CanJmpScriptLableList)
                {
                    if (string.Compare(sLabel, item, true) == 0)
                    {
                        result = true;
                        break;
                    }
                }
            }
            if (string.Compare(sLabel, m_sPlayDiceLabel, true) == 0)
            {
                m_sPlayDiceLabel = "";
                result = true;
                return result;
            }
            return result;
        }

        /// <summary>
        /// 刷新对象属性
        /// </summary>
        public override void RecalcAbilitys()
        {
            base.RecalcAbilitys();
            RecalcAdjusBonus();
        }

        /// <summary>
        /// 挂机后,清除相关列表
        /// </summary>
        public void ClearViewRange()
        {
            try
            {
                this.m_VisibleHumanList.Clear();
                if (this.m_VisibleItems.Count > 0)
                {
                    for (int i = 0; i < this.m_VisibleItems.Count; i++)
                    {
                        if (this.m_VisibleItems[i] != null)
                        {
                            Dispose(this.m_VisibleItems[i]);
                        }
                    }
                }
                this.m_VisibleItems.Clear();//清除物品列表
                if (this.m_VisibleActors.Count > 0)
                {
                    for (int i = 0; i < this.m_VisibleActors.Count; i++)
                    {
                        if (this.m_VisibleActors[i] != null)
                        {
                            Dispose(this.m_VisibleActors[i]);
                        }
                    }
                }
                this.m_VisibleActors.Clear(); // 清除人物列表
                if (this.m_VisibleEvents.Count > 0)
                {
                    for (int i = 0; i < this.m_VisibleEvents.Count; i++)
                    {
                        if (this.m_VisibleEvents[i] != null)
                        {
                            Dispose(this.m_VisibleEvents[i]);
                        }
                    }
                }
                this.m_VisibleEvents.Clear();//清除事件列表
            }
            catch
            {
                this.KickException();
            }
        }

        /// <summary>
        /// 检查物品使用要求
        /// </summary>
        /// <param name="StdItem"></param>
        /// <returns></returns>
        private bool CheckItemsNeed(TStdItem StdItem)
        {
            bool result = true;
            TUserCastle Castle;
            Castle = M2Share.g_CastleManager.IsCastleMember(this);
            switch (StdItem.Need)
            {
                case 6:
                    if ((this.m_MyGuild == null))
                    {
                        result = false;
                    }
                    break;
                case 60:
                    if ((this.m_MyGuild == null) || (this.m_nGuildRankNo != 1))
                    {
                        result = false;
                    }
                    break;
                case 7:
                    if (Castle == null)
                    {
                        result = false;
                    }
                    break;
                case 70:
                    if ((Castle == null) || (this.m_nGuildRankNo != 1))
                    {
                        result = false;
                    }
                    break;
                case 8:
                    if (m_nMemberType == 0)
                    {
                        result = false;
                    }
                    break;
                case 81:
                    if ((m_nMemberType != HUtil32.LoWord(StdItem.NeedLevel)) || (m_nMemberLevel < HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = false;
                    }
                    break;
                case 82:
                    if ((m_nMemberType < HUtil32.LoWord(StdItem.NeedLevel)) || (m_nMemberLevel < HUtil32.HiWord(StdItem.NeedLevel)))
                    {
                        result = false;
                    }
                    break;
            }
            return result;
        }

        private void CheckMarry()
        {
            bool boIsfound;
            string sUnMarryFileName;
            TStringList LoadList;
            
            string sSayMsg;
            boIsfound = false;
            sUnMarryFileName = M2Share.g_Config.sEnvirDir + "UnMarry.txt";
            if (File.Exists(sUnMarryFileName))
            {
                LoadList = new TStringList();
                LoadList.LoadFromFile(sUnMarryFileName);
                for (var i = LoadList.Count - 1; i >= 0; i--)
                {
                    if (LoadList.Count <= 0)
                    {
                        break;
                    }
                    if ((LoadList[i]).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0)
                    {
                        LoadList.RemoveAt(i);
                        boIsfound = true;
                        break;
                    }
                }
                LoadList.SaveToFile(sUnMarryFileName);
                Dispose(LoadList);
            }
            if (boIsfound)
            {
                if (this.m_btGender == 0)
                {
                    sSayMsg = GameMsgDef.g_sfUnMarryManLoginMsg.Replace("%d", m_sDearName);
                    sSayMsg = sSayMsg.Replace("%s", m_sDearName);
                }
                else
                {
                    sSayMsg = GameMsgDef.g_sfUnMarryWoManLoginMsg.Replace("%d", this.m_sCharName);
                    sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                }
                this.SysMsg(sSayMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                m_sDearName = "";
                this.RefShowName();
            }
            m_DearHuman = M2Share.UserEngine.GetPlayObject(m_sDearName);
            if (m_DearHuman != null)
            {
                m_DearHuman.m_DearHuman = this;
                if (this.m_btGender == 0)
                {
                    sSayMsg = GameMsgDef.g_sManLoginDearOnlineSelfMsg.Replace("%d", m_sDearName);
                    sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                    sSayMsg = sSayMsg.Replace("%m", m_DearHuman.m_PEnvir.sMapDesc);
                    sSayMsg = sSayMsg.Replace("%x", (m_DearHuman.m_nCurrX).ToString());
                    sSayMsg = sSayMsg.Replace("%y", (m_DearHuman.m_nCurrY).ToString());
                    this.SysMsg(sSayMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                    sSayMsg = GameMsgDef.g_sManLoginDearOnlineDearMsg.Replace("%d", m_sDearName);
                    sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                    sSayMsg = sSayMsg.Replace("%m", this.m_PEnvir.sMapDesc);
                    sSayMsg = sSayMsg.Replace("%x", (this.m_nCurrX).ToString());
                    sSayMsg = sSayMsg.Replace("%y", (this.m_nCurrY).ToString());
                    m_DearHuman.SysMsg(sSayMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                }
                else
                {
                    sSayMsg = GameMsgDef.g_sWoManLoginDearOnlineSelfMsg.Replace("%d", m_sDearName);
                    sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                    sSayMsg = sSayMsg.Replace("%m", m_DearHuman.m_PEnvir.sMapDesc);
                    sSayMsg = sSayMsg.Replace("%x", (m_DearHuman.m_nCurrX).ToString());
                    sSayMsg = sSayMsg.Replace("%y", (m_DearHuman.m_nCurrY).ToString());
                    this.SysMsg(sSayMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                    sSayMsg = GameMsgDef.g_sWoManLoginDearOnlineDearMsg.Replace("%d", m_sDearName);
                    sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                    sSayMsg = sSayMsg.Replace("%m", this.m_PEnvir.sMapDesc);
                    sSayMsg = sSayMsg.Replace("%x", (this.m_nCurrX).ToString());
                    sSayMsg = sSayMsg.Replace("%y", (this.m_nCurrY).ToString());
                    m_DearHuman.SysMsg(sSayMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                }
            }
            else
            {
                if (this.m_btGender == 0)
                {
                    this.SysMsg(GameMsgDef.g_sManLoginDearNotOnlineMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                }
                else
                {
                    this.SysMsg(GameMsgDef.g_sWoManLoginDearNotOnlineMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                }
            }
        }

        // 检查师傅
        private void CheckMaster()
        {
            bool boIsfound;
            string sSayMsg;
            
            TPlayObject Human;
            string s01 = string.Empty;
            string s02 = string.Empty;
            string s03 = string.Empty;// 处理强行脱离师徒关系
            boIsfound = false;
            M2Share.g_UnForceMasterList.__Lock();
            try
            {
                for (var i = M2Share.g_UnForceMasterList.Count - 1; i >= 0; i--)
                {
                    if (M2Share.g_UnForceMasterList.Count <= 0)
                    {
                        break;
                    }
                    s01 = M2Share.g_UnForceMasterList[i].Trim();
                    if ((s01 != "") && (s01[0] != ';'))
                    {
                        s01 = HUtil32.GetValidStr3(s01, ref s02, new string[] { " ", "\09" });// 师傅名
                        s01 = HUtil32.GetValidStr3(s01, ref s03, new string[] { " ", "\09" });// 徒弟名
                        if ((s02).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0)
                        {
                            M2Share.g_UnForceMasterList.RemoveAt(i);
                            M2Share.SaveUnForceMasterList();
                            boIsfound = true;
                            break;
                        }
                    }
                }
            }
            finally
            {
                M2Share.g_UnForceMasterList.UnLock();
            }
            if (boIsfound)
            {
                if (m_boMaster)
                {
                    sSayMsg = GameMsgDef.g_sfUnMasterLoginMsg.Replace("%d", s03);//
                    DelMaster(s03);// 出师
                    if (M2Share.g_FunctionNPC != null)
                    {
                        M2Share.g_FunctionNPC.GotoLable(this, "@UnMasterEnd", false); // 师傅触发
                    }
                }
                else
                {
                    sSayMsg = GameMsgDef.g_sfUnMasterListLoginMsg.Replace("%d", m_sMasterName);
                }
                this.SysMsg(sSayMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                m_sMasterName = "";
                this.RefShowName();
            }
            if ((m_sMasterName != "") && !m_boMaster)
            {
                if (this.m_Abil.Level >= M2Share.g_Config.nMasterOKLevel)
                {
                    Human = M2Share.UserEngine.GetPlayObject(m_sMasterName);
                    if ((Human != null) && (!Human.m_boDeath) && (!Human.m_boGhost))
                    {
                        sSayMsg = GameMsgDef.g_sYourMasterListUnMasterOKMsg.Replace("%d", this.MoneyToCharacter(m_nMasterNo));
                        sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                        Human.SysMsg(sSayMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                        this.SysMsg(GameMsgDef.g_sYouAreUnMasterOKMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                        Human.DelMaster(this.m_sCharName);// 出师 20080603
                        if (this.m_sCharName == Human.m_sMasterName)// 如果大徒弟则将师父上的名字去掉
                        {
                            Human.m_sMasterName = "";
                            Human.RefShowName();
                        }
                        for (var i = Human.m_MasterList.Count - 1; i >= 0; i--)
                        {
                            if (Human.m_MasterList.Count <= 0)
                            {
                                break;
                            }
                            if (Human.m_MasterList[i] == this)
                            {
                                Human.m_MasterList.RemoveAt(i);
                                break;
                            }
                        }
                        m_sMasterName = "";
                        this.RefShowName();
                        Human.m_wMasterCount++;// 增加出师徒弟数
                        Human.m_btCreditPoint += M2Share.g_Config.nMasterOKCreditPoint;// 增加师傅的声望
                        Human.m_nBonusPoint += M2Share.g_Config.nMasterOKBonusPoint;
                        Human.SendMsg(Human, Grobal2.RM_ADJUST_BONUS, 0, 0, 0, 0, "");
                    }
                    else
                    {
                        // 如果师父不在线则保存到记录表中
                        M2Share.g_UnMasterList.__Lock();
                        try
                        {
                            boIsfound = false;
                            if (M2Share.g_UnMasterList.Count > 0)
                            {
                                for (var i = 0; i < M2Share.g_UnMasterList.Count; i++)
                                {
                                    s01 = M2Share.g_UnMasterList[i].Trim();
                                    if ((s01 != "") && (s01[0] != ';'))
                                    {
                                        s01 = HUtil32.GetValidStr3(s01, ref s02, new string[] { " ", "\09" });// 师傅名
                                        s01 = HUtil32.GetValidStr3(s01, ref s03, new string[] { " ", "\09" });
                                        if ((s02).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0)
                                        {
                                            boIsfound = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!boIsfound)
                            {
                                //M2Share.g_UnMasterList.Add(m_sMasterName + " " + this.m_sCharName);
                            }
                        }
                        finally
                        {
                            M2Share.g_UnMasterList.UnLock();
                        }
                        if (!boIsfound)
                        {
                            M2Share.SaveUnMasterList();
                        }
                        this.SysMsg(GameMsgDef.g_sYouAreUnMasterOKMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                        m_sMasterName = "";
                        this.RefShowName();
                    }
                }
            }
            // 处理出师记录
            boIsfound = false;
            // M2Share.g_UnMasterList.__Lock();
            try
            {
                for (var i = M2Share.g_UnMasterList.Count - 1; i >= 0; i--)
                {
                    if (M2Share.g_UnMasterList.Count <= 0)
                    {
                        break;
                    }
                    s01 = M2Share.g_UnMasterList[i].Trim();
                    if ((s01 != "") && (s01[0] != ';'))
                    {
                        // 20080603 增加
                        s01 = HUtil32.GetValidStr3(s01, ref s02, new string[] { " ", "\09" });// 师傅名
                        s01 = HUtil32.GetValidStr3(s01, ref s03, new string[] { " ", "\09" });// 徒弟名
                        if ((s02).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0)
                        {
                            M2Share.g_UnMasterList.RemoveAt(i);
                            M2Share.SaveUnMasterList();
                            boIsfound = true;
                            break;
                        }
                    }
                }
            }
            finally
            {
                // M2Share.g_UnMasterList.UnLock();
            }
            if (boIsfound && m_boMaster)
            {
                sSayMsg = GameMsgDef.g_sUnMasterLoginMsg.Replace("%s", s03);
                this.SysMsg(sSayMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                DelMaster(s03);// 出师
                m_sMasterName = "";
                this.RefShowName();
                m_wMasterCount++;// 增加出师徒弟数
                m_btCreditPoint += M2Share.g_Config.nMasterOKCreditPoint;
                this.m_nBonusPoint += M2Share.g_Config.nMasterOKBonusPoint;
                this.SendMsg(this, Grobal2.RM_ADJUST_BONUS, 0, 0, 0, 0, "");
            }
            if (m_boMaster) // 是师傅
            {
                m_MasterHuman = M2Share.UserEngine.GetMasterObject(this.m_sCharName); // 师父上线通知
                if (m_MasterHuman != null)
                {
                    m_MasterHuman.m_MasterHuman = this;
                    m_MasterList.Add(m_MasterHuman);
                    sSayMsg = GameMsgDef.g_sMasterOnlineSelfMsg.Replace("%d", this.MoneyToCharacter(m_nMasterNo));
                    sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                    sSayMsg = sSayMsg.Replace("%m", m_MasterHuman.m_PEnvir.sMapDesc);
                    sSayMsg = sSayMsg.Replace("%x", (m_MasterHuman.m_nCurrX).ToString());
                    sSayMsg = sSayMsg.Replace("%y", (m_MasterHuman.m_nCurrY).ToString());
                    this.SysMsg(sSayMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                    sSayMsg = GameMsgDef.g_sMasterOnlineMasterListMsg.Replace("%d", m_sMasterName);
                    sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                    sSayMsg = sSayMsg.Replace("%m", this.m_PEnvir.sMapDesc);
                    sSayMsg = sSayMsg.Replace("%x", (this.m_nCurrX).ToString());
                    sSayMsg = sSayMsg.Replace("%y", (this.m_nCurrY).ToString());
                    m_MasterHuman.SysMsg(sSayMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                }
                else
                {
                    if (m_MasterNoList.Count != 0)
                    {
                        this.SysMsg(GameMsgDef.g_sMasterNotOnlineMsg, TMsgColor.c_Red, TMsgType.t_Hint);// 您的徒弟现不在线
                    }
                }
            }
            else
            {
                // 徒弟上线通知
                if (m_sMasterName != "")
                {
                    m_MasterHuman = M2Share.UserEngine.GetPlayObject(m_sMasterName);
                    if (m_MasterHuman != null)
                    {
                        if (m_MasterHuman.m_sMasterName == this.m_sCharName)
                        {
                            m_MasterHuman.m_MasterHuman = this;
                        }
                        m_MasterHuman.m_MasterList.Add(this);
                        sSayMsg = GameMsgDef.g_sMasterListOnlineSelfMsg.Replace("%d", m_sMasterName);
                        sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                        sSayMsg = sSayMsg.Replace("%m", m_MasterHuman.m_PEnvir.sMapDesc);
                        sSayMsg = sSayMsg.Replace("%x", (m_MasterHuman.m_nCurrX).ToString());
                        sSayMsg = sSayMsg.Replace("%y", (m_MasterHuman.m_nCurrY).ToString());
                        this.SysMsg(sSayMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                        sSayMsg = GameMsgDef.g_sMasterListOnlineMasterMsg.Replace("%d", this.MoneyToCharacter(m_nMasterNo));
                        sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                        sSayMsg = sSayMsg.Replace("%m", this.m_PEnvir.sMapDesc);
                        sSayMsg = sSayMsg.Replace("%x", (this.m_nCurrX).ToString());
                        sSayMsg = sSayMsg.Replace("%y", (this.m_nCurrY).ToString());
                        m_MasterHuman.SysMsg(sSayMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                    }
                    else
                    {
                        // 您的师父现不在线
                        this.SysMsg(GameMsgDef.g_sMasterListNotOnlineMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                }
            }
        }

        /// <summary>
        /// 取玩家数据
        /// </summary>
        /// <returns></returns>
        public string GetMyInfo()
        {
            string sMyInfo;
            sMyInfo = GameMsgDef.g_sMyInfo;
            sMyInfo = sMyInfo.Replace("%name", this.m_sCharName);
            sMyInfo = sMyInfo.Replace("%map", this.m_PEnvir.sMapDesc);
            sMyInfo = sMyInfo.Replace("%x", (this.m_nCurrX).ToString());
            sMyInfo = sMyInfo.Replace("%y", (this.m_nCurrY).ToString());
            sMyInfo = sMyInfo.Replace("%level", (this.m_Abil.Level).ToString());
            sMyInfo = sMyInfo.Replace("%gold", (this.m_nGold).ToString());
            sMyInfo = sMyInfo.Replace("%pk", (this.m_nPkPoint).ToString());
            sMyInfo = sMyInfo.Replace("%minhp", (this.m_WAbil.HP).ToString());
            sMyInfo = sMyInfo.Replace("%maxhp", (this.m_WAbil.MaxHP).ToString());
            sMyInfo = sMyInfo.Replace("%minmp", (this.m_WAbil.MP).ToString());
            sMyInfo = sMyInfo.Replace("%maxmp", (this.m_WAbil.MaxMP).ToString());
            sMyInfo = sMyInfo.Replace("%mindc", (HUtil32.LoWord(this.m_WAbil.DC)).ToString());
            sMyInfo = sMyInfo.Replace("%maxdc", (HUtil32.HiWord(this.m_WAbil.DC)).ToString());
            sMyInfo = sMyInfo.Replace("%minmc", (HUtil32.LoWord(this.m_WAbil.MC)).ToString());
            sMyInfo = sMyInfo.Replace("%maxmc", (HUtil32.HiWord(this.m_WAbil.MC)).ToString());
            sMyInfo = sMyInfo.Replace("%minsc", (HUtil32.LoWord(this.m_WAbil.SC)).ToString());
            sMyInfo = sMyInfo.Replace("%maxsc", (HUtil32.HiWord(this.m_WAbil.SC)).ToString());
            sMyInfo = sMyInfo.Replace("%logontime", (m_dLogonTime).ToString());
            sMyInfo = sMyInfo.Replace("%logonlong", ((HUtil32.GetTickCount() - m_dwLogonTick) / 60000).ToString());
            return sMyInfo;
        }

        // 检查物品是当前账号的捆绑物品
        private bool CheckItemBindUse(TUserItem UserItem)
        {
            bool result;
            
            TItemBind ItemBind = null;
            result = true;
            // M2Share.g_ItemBindAccount.__Lock();
            try
            {
                if (M2Share.g_ItemBindAccount.Count > 0)
                {
                    for (var i = 0; i < M2Share.g_ItemBindAccount.Count; i++)
                    {
                        ItemBind = M2Share.g_ItemBindAccount[i];
                        if (ItemBind != null)
                        {
                            if ((ItemBind.nMakeIdex == UserItem.MakeIndex) && (ItemBind.nItemIdx == UserItem.wIndex))
                            {
                                result = false;
                                if (((ItemBind.sBindName).ToLower().CompareTo((m_sUserID).ToLower()) == 0))
                                {
                                    result = true;
                                }
                                else
                                {
                                    this.SysMsg(GameMsgDef.g_sItemIsNotThisAccount, TMsgColor.c_Red, TMsgType.t_Hint);
                                }
                                return result;
                            }
                        }
                    }
                }
            }
            finally
            {
                //M2Share.g_ItemBindAccount.UnLock();
            }
            //M2Share.g_ItemBindIPaddr.__Lock();
            try
            {
                if (M2Share.g_ItemBindIPaddr.Count > 0)
                {
                    for (var i = 0; i < M2Share.g_ItemBindIPaddr.Count; i++)
                    {
                        ItemBind = M2Share.g_ItemBindIPaddr[i];
                        if (ItemBind != null)
                        {
                            if ((ItemBind.nMakeIdex == UserItem.MakeIndex) && (ItemBind.nItemIdx == UserItem.wIndex))
                            {
                                result = false;
                                if (((ItemBind.sBindName).ToLower().CompareTo((m_sIPaddr).ToLower()) == 0))
                                {
                                    result = true;
                                }
                                else
                                {
                                    this.SysMsg(GameMsgDef.g_sItemIsNotThisIPaddr, TMsgColor.c_Red, TMsgType.t_Hint);
                                }
                                return result;
                            }
                        }
                    }
                }
            }
            finally
            {
                // M2Share.g_ItemBindIPaddr.UnLock();
            }
            // M2Share.g_ItemBindCharName.__Lock();
            try
            {
                if (M2Share.g_ItemBindCharName.Count > 0)
                {
                    for (var i = 0; i < M2Share.g_ItemBindCharName.Count; i++)
                    {
                        //ItemBind = M2Share.g_ItemBindCharName[i];
                        if (ItemBind != null)
                        {
                            if ((ItemBind.nMakeIdex == UserItem.MakeIndex) && (ItemBind.nItemIdx == UserItem.wIndex))
                            {
                                result = false;
                                if (((ItemBind.sBindName).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0))
                                {
                                    result = true;
                                }
                                else
                                {
                                    this.SysMsg(GameMsgDef.g_sItemIsNotThisCharName, TMsgColor.c_Red, TMsgType.t_Hint);
                                }
                                return result;
                            }
                        }
                    }
                }
            }
            finally
            {
                //M2Share.g_ItemBindCharName.UnLock();
            }
            return result;
        }

        private void ProcessClientPassword(TProcessMessage ProcessMsg)
        {
            int nLen;
            string sData;
            if (ProcessMsg.wParam == 0)
            {
                ProcessUserLineMsg("@" + M2Share.g_GameCommand.UnLock.sCmd);
                return;
            }
            sData = ProcessMsg.sMsg;
            nLen = sData.Length;
            if (m_boSetStoragePwd)
            {
                m_boSetStoragePwd = false;
                if ((nLen > 3) && (nLen < 8))
                {
                    m_sTempPwd = sData;
                    m_boReConfigPwd = true;
                    this.SysMsg(GameMsgDef.g_sReSetPasswordMsg, TMsgColor.c_Green, TMsgType.t_Hint);// '请重复输入一次仓库密码：'
                    this.SendMsg(this, Grobal2.RM_PASSWORD, 0, 0, 0, 0, "");
                }
                else
                {
                    this.SysMsg(GameMsgDef.g_sPasswordOverLongMsg, TMsgColor.c_Red, TMsgType.t_Hint);// '输入的密码长度不正确！！！，密码长度必须在 4 - 7 的范围内，请重新设置密码。'
                }
                return;
            }
            if (m_boReConfigPwd)
            {
                m_boReConfigPwd = false;
                if (m_sTempPwd.CompareTo(sData) == 0)
                {
                    m_sStoragePwd = sData;
                    m_boPasswordLocked = true;
                    m_sTempPwd = "";
                    this.SysMsg(GameMsgDef.g_sReSetPasswordOKMsg, TMsgColor.c_Blue, TMsgType.t_Hint);// '密码设置成功！！，仓库已经自动上锁，请记好您的仓库密码，在取仓库时需要使用此密码开锁。'
                }
                else
                {
                    m_sTempPwd = "";
                    this.SysMsg(GameMsgDef.g_sReSetPasswordNotMatchMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                }
                return;
            }
            if (m_boUnLockPwd || m_boUnLockStoragePwd)
            {
                if (m_sStoragePwd.CompareTo(sData) == 0)
                {
                    m_boPasswordLocked = false;
                    if (m_boUnLockPwd)
                    {
                        if (M2Share.g_Config.boLockDealAction)
                        {
                            m_boCanDeal = true;
                        }
                        if (M2Share.g_Config.boLockDropAction)
                        {
                            m_boCanDrop = true;
                        }
                        if (M2Share.g_Config.boLockWalkAction)
                        {
                            m_boCanWalk = true;
                        }
                        if (M2Share.g_Config.boLockRunAction)
                        {
                            m_boCanRun = true;
                        }
                        if (M2Share.g_Config.boLockHitAction)
                        {
                            m_boCanHit = true;
                        }
                        if (M2Share.g_Config.boLockSpellAction)
                        {
                            m_boCanSpell = true;
                        }
                        if (M2Share.g_Config.boLockCallHeroAction)
                        {
                            m_boCallHero = true;
                        }
                        // 是否锁定召唤英雄操作
                        if (M2Share.g_Config.boLockSendMsgAction)
                        {
                            m_boCanSendMsg = true;
                        }
                        if (M2Share.g_Config.boLockUserItemAction)
                        {
                            m_boCanUseItem = true;
                        }
                        if (M2Share.g_Config.boLockInObModeAction)
                        {
                            this.m_boObMode = false;
                            this.m_boAdminMode = false;
                        }
                        m_boLockLogoned = true;
                        this.SysMsg(GameMsgDef.g_sPasswordUnLockOKMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                    }
                    if (m_boUnLockStoragePwd)
                    {
                        if (M2Share.g_Config.boLockGetBackItemAction)
                        {
                            m_boCanGetBackItem = true;
                        }
                        this.SysMsg(GameMsgDef.g_sStorageUnLockOKMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                    }
                }
                else
                {
                    m_btPwdFailCount++;
                    this.SysMsg(GameMsgDef.g_sUnLockPasswordFailMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    if (m_btPwdFailCount > 3)
                    {
                        this.SysMsg(GameMsgDef.g_sStoragePasswordLockedMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                }
                m_boUnLockPwd = false;
                m_boUnLockStoragePwd = false;
                return;
            }
            if (m_boCheckOldPwd)
            {
                m_boCheckOldPwd = false;
                if (m_sStoragePwd == sData)
                {
                    this.SendMsg(this, Grobal2.RM_PASSWORD, 0, 0, 0, 0, "");
                    this.SysMsg(GameMsgDef.g_sSetPasswordMsg, TMsgColor.c_Green, TMsgType.t_Hint);
                    m_boSetStoragePwd = true;
                }
                else
                {
                    m_btPwdFailCount++;
                    this.SysMsg(GameMsgDef.g_sOldPasswordIncorrectMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    if (m_btPwdFailCount > 3)
                    {
                        this.SysMsg(GameMsgDef.g_sStoragePasswordLockedMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                        m_boPasswordLocked = true;
                    }
                }
                return;
            }
        }

        /// <summary>
        /// 人物死亡掉背包物品
        /// </summary>
        /// <param name="ItemOfCreat"></param>
        public override void ScatterBagItems(TBaseObject ItemOfCreat)
        {
            int DropWide;
            TUserItem pu;
            List<string> DelList = null;
            bool boDropall;
            string sCheckItemName;
            TStdItem StdItem;
            const string sExceptionMsg = "[异常] TPlayObject::ScatterBagItems";
            m_boCanQueryBag = true;// 死亡掉背包时,不能�           }
            if (this.m_PEnvir.m_boNODROPITEM) // 地图禁止死亡掉物品则退出
            {
                return;
            }
            boDropall = false;
            DropWide = 2;
            if (M2Share.g_Config.boDieRedScatterBagAll && (this.PKLevel() >= 2))// 非红名掉1/3 //红名全掉
            {
                boDropall = true;
            }
            try
            {
                for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                {
                    if (this.m_ItemList.Count <= 0)
                    {
                        break;
                    }
                    if (boDropall || (HUtil32.Random(M2Share.g_Config.nDieScatterBagRate) == 0))
                    {
                        if (this.m_ItemList[i] != null)
                        {
                            pu = this.m_ItemList[i];
                            sCheckItemName = M2Share.UserEngine.GetStdItemName(pu.wIndex);
                            if (this.PlugOfCheckCanItem(6, sCheckItemName, false, 0, 0)) // 禁止物品规则(永不爆出)
                            {
                                continue;
                            }
                            if (CheckItemBindDieNoDrop(this.m_ItemList[i]))// 人物装备绑定死亡不爆
                            {
                                continue;
                            }
                            StdItem = M2Share.UserEngine.GetStdItem(pu.wIndex);
                            if (StdItem != null)
                            {
                                if ((StdItem.StdMode == 51) && (StdItem.Shape == 0) && (pu.Dura > 0) && (pu.btValue[20] == 1))// 是聚灵珠
                                {
                                    n_UsesItemTick = 0;  // 时间初始
                                    pu.btValue[12] = 2; // 不能聚集的标识
                                }
                            }
                            if (this.DropItemDown(this.m_ItemList[i], DropWide, true, true, ItemOfCreat, this))
                            {
                                if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                {
                                    if (DelList == null)
                                    {
                                        DelList = new List<string>();
                                    }
                                    //DelList.Add(M2Share.UserEngine.GetStdItemName(pu.wIndex), ((pu.MakeIndex) as Object));
                                }
                                //Marshal.FreeHGlobal((IntPtr)this.m_ItemList[i]);
                                this.m_ItemList.RemoveAt(i);
                            }
                        }
                    }
                }
                if (DelList != null)
                {
                    Console.WriteLine("todo RM_SENDDELITEMLIST...");
                    //this.SendMsg(this, Grobal2.RM_SENDDELITEMLIST, 0, DelList.ToInt(), 0, 0, "");
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg);
            }
            finally
            {
                m_boCanQueryBag = false;// 死亡掉背包时,不能刷新包裹
            }
        }

        /// <summary>
        /// 召唤人物
        /// </summary>
        /// <param name="sHumName"></param>
        public void RecallHuman(string sHumName)
        {
            TPlayObject PlayObject;
            int nX = 0;
            int nY = 0;
            int n18 = 0;
            int n1C = 0;
            PlayObject = M2Share.UserEngine.GetPlayObject(sHumName);
            if (PlayObject != null)
            {
                if (this.GetFrontPosition(ref nX, ref nY))
                {
                    if (this.sub_4C5370(nX, nY, 3, ref n18, ref n1C))
                    {
                        PlayObject.SendRefMsg(Grobal2.RM_SPACEMOVE_FIRE, 0, 0, 0, 0, "");
                        PlayObject.SpaceMove(this.m_sMapName, n18, n1C, 0);
                    }
                }
                else
                {
                    this.SysMsg("召唤失败！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                }
            }
            else
            {
                this.SysMsg(string.Format(GameMsgDef.g_sNowNotOnLineOrOnOtherServer, sHumName), TMsgColor.c_Red, TMsgType.t_Hint);
            }
        }

        /// <summary>
        /// 申请行会战
        /// </summary>
        /// <param name="sGuildName"></param>
        public void ReQuestGuildWar(string sGuildName)
        {
            TGUild Guild;
            TWarGuild WarGuild;
            bool boReQuestOK;
            if (!this.IsGuildMaster())
            {
                this.SysMsg("只有行会掌门人才能申请！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                return;
            }
            if (M2Share.nServerIndex != 0)
            {
                this.SysMsg("这个命令不能在本服务器上使用！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                return;
            }
            Guild = M2Share.g_GuildManager.FindGuild(sGuildName);
            if (Guild == null)
            {
                this.SysMsg("行会不存在！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                return;
            }
            boReQuestOK = false;
            WarGuild = this.m_MyGuild.AddWarGuild(Guild);
            if (WarGuild != null)
            {
                if (Guild.AddWarGuild(this.m_MyGuild) == null)
                {
                    WarGuild.dwWarTick = 0;
                }
                else
                {
                    boReQuestOK = true;
                }
            }
            if (boReQuestOK)
            {
                M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, this.m_MyGuild.sGuildName);
                M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, Guild.sGuildName);
            }
        }

        private bool CheckDenyLogon()
        {
            bool result = false;
            if (M2Share.GetDenyIPaddrList(m_sIPaddr))
            {
                this.SysMsg(GameMsgDef.g_sYourIPaddrDenyLogon, TMsgColor.c_Red, TMsgType.t_Hint);
                result = true;
            }
            else if (M2Share.GetDenyAccountList(m_sUserID))
            {
                this.SysMsg(GameMsgDef.g_sYourAccountDenyLogon, TMsgColor.c_Red, TMsgType.t_Hint);
                result = true;
            }
            else if (M2Share.GetDenyChrNameList(this.m_sCharName))
            {
                this.SysMsg(GameMsgDef.g_sYourCharNameDenyLogon, TMsgColor.c_Red, TMsgType.t_Hint);
                result = true;
            }
            if (result)
            {
                m_boEmergencyClose = true;
                m_boPlayOffLine = false;
            }
            return result;
        }

        public bool IsGotoLabel_GetAllowItem(string sItemName1, string sItemName2)
        {
            bool result = false;
            if (sItemName1 == "*")
            {
                result = true;
            }
            else if ((sItemName1).ToLower().CompareTo((sItemName2).ToLower()) == 0)
            {
                result = true;
            }
            return result;
        }

        public bool IsGotoLabel_GetRandomCount(int nRandomCount)
        {
            bool result = false;
            if (nRandomCount == 0)
            {
                result = true;
            }
            else if ((nRandomCount > 0) && (HUtil32.Random(nRandomCount / 2 + nRandomCount) == nRandomCount))
            {
                result = true;
            }
            return result;
        }

        public bool IsGotoLabel_GetGroup(bool boNeedGroup)
        {
            bool result = false;
            if (!boNeedGroup)
            {
                result = true;
            }
            else if (m_GroupOwner != null)
            {
                result = true;
            }
            return result;
        }

        /// <summary>
        /// 是否跳转标签
        /// </summary>
        /// <returns></returns>
        public bool IsGotoLabel(string sMapName, int nX, int nY, int nRange, int nQuestFalgStatus, bool boQuestFalgStatus, string sItemName1, string sItemName2, bool boNeedGroup, int nRandomCount)
        {
            bool result;
            int n01;
            int nMaxCurrX;
            int nMaxCurrY;
            int nMinCurrX;
            int nMinCurrY;
            result = false;
            nMaxCurrX = nX + nRange;
            nMaxCurrY = nY + nRange;
            nMinCurrX = nX - nRange;
            nMinCurrY = nY - nRange;
            if (((sMapName).ToLower().CompareTo((this.m_sMapName).ToLower()) == 0) && (this.m_nCurrX <= nMaxCurrX) && (this.m_nCurrX >= nMinCurrX)
                && (this.m_nCurrY <= nMaxCurrY) && (this.m_nCurrY >= nMinCurrY))
            {
                if (nQuestFalgStatus > 0)
                {
                    n01 = this.GetQuestFalgStatus(nQuestFalgStatus);
                    if ((n01 == 0) && !boQuestFalgStatus)
                    {
                        if (IsGotoLabel_GetAllowItem(sItemName1, sItemName2) && IsGotoLabel_GetGroup(boNeedGroup) && IsGotoLabel_GetRandomCount(nRandomCount))
                        {
                            result = true;
                        }
                    }
                    else if ((n01 != 0) && boQuestFalgStatus)
                    {
                        if (IsGotoLabel_GetAllowItem(sItemName1, sItemName2) && IsGotoLabel_GetGroup(boNeedGroup) && IsGotoLabel_GetRandomCount(nRandomCount))
                        {
                            result = true;
                        }
                    }
                }
                else
                {
                    if (IsGotoLabel_GetAllowItem(sItemName1, sItemName2) && IsGotoLabel_GetGroup(boNeedGroup) && IsGotoLabel_GetRandomCount(nRandomCount))
                    {
                        result = true;
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// 地图事件触发-掉落物品
        /// </summary>
        /// <param name="sItemName"></param>
        public void StartMapEventOfDropItem(string sItemName)
        {
            bool boGotoLabel = false;
            TMapEvent MapEvent = null;
            try
            {
                if (M2Share.g_MapEventListOfDropItem.Count > 0)
                {
                    for (int i = 0; i < M2Share.g_MapEventListOfDropItem.Count; i++)
                    {
                        MapEvent = M2Share.g_MapEventListOfDropItem[i];
                        if (MapEvent != null)
                        {
                            if (IsGotoLabel(MapEvent.m_sMapName, MapEvent.m_nCurrX, MapEvent.m_nCurrY, MapEvent.m_nRange, MapEvent.m_MapFlag.nQuestUnit, MapEvent.m_MapFlag.boOpen,
                                MapEvent.m_Condition.sItemName, sItemName, MapEvent.m_Condition.boNeedGroup, MapEvent.m_nRandomCount))
                            {
                                boGotoLabel = true;
                                break;
                            }
                        }
                    }

                    if (boGotoLabel && (MapEvent != null))
                    {
                        switch (MapEvent.m_StartScript.nLable)
                        {
                            case 0:
                                break;
                            case 1:
                                if (M2Share.g_FunctionNPC != null)
                                {
                                    M2Share.g_FunctionNPC.GotoLable(this, MapEvent.m_StartScript.sLable, false);
                                }
                                break;
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.StartMapEventOfDropItem");
            }
        }

        /// <summary>
        /// 地图事件触发-捡起物品
        /// </summary>
        /// <param name="sItemName"></param>
        public void StartMapEventOfPickUpItem(string sItemName)
        {
            bool boGotoLabel;
            TMapEvent MapEvent;
            byte nCode = 0;
            try
            {
                nCode = 0;
                MapEvent = null;
                boGotoLabel = false;
                nCode = 1;
                if (M2Share.g_MapEventListOfPickUpItem.Count > 0)
                {
                    nCode = 2;
                    for (int i = 0; i < M2Share.g_MapEventListOfPickUpItem.Count; i++)
                    {
                        nCode = 3;
                        MapEvent = M2Share.g_MapEventListOfPickUpItem[i];
                        nCode = 4;
                        if (MapEvent != null)
                        {
                            nCode = 5;
                            if (IsGotoLabel(MapEvent.m_sMapName, MapEvent.m_nCurrX, MapEvent.m_nCurrY, MapEvent.m_nRange, MapEvent.m_MapFlag.nQuestUnit, MapEvent.m_MapFlag.boOpen,
                                MapEvent.m_Condition.sItemName, sItemName, MapEvent.m_Condition.boNeedGroup, MapEvent.m_nRandomCount))
                            {
                                boGotoLabel = true;
                                break;
                            }
                        }
                    }
                }
                if (boGotoLabel && (MapEvent != null))
                {
                    switch (MapEvent.m_StartScript.nLable)
                    {
                        case 0:
                            break;
                        case 1:
                            if (M2Share.g_FunctionNPC != null)
                            {
                                nCode = 6;
                                M2Share.g_FunctionNPC.GotoLable(this, MapEvent.m_StartScript.sLable, false);
                            }
                            break;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.StartMapEventOfPickUpItem Code:" + (nCode).ToString());
            }
        }

        /// <summary>
        /// 地图事件触发-挖矿
        /// </summary>
        public void StartMapEventOfMine()
        {
            bool boGotoLabel;
            TMapEvent MapEvent;
            byte nCode = 0;
            try
            {
                nCode = 0;
                MapEvent = null;
                boGotoLabel = false;
                nCode = 1;
                if (M2Share.g_MapEventListOfMine.Count > 0)
                {
                    nCode = 2;
                    for (int i = 0; i < M2Share.g_MapEventListOfMine.Count; i++)
                    {
                        nCode = 3;
                        MapEvent = M2Share.g_MapEventListOfMine[i];
                        nCode = 4;
                        if (MapEvent != null)
                        {
                            nCode = 5;
                            if (IsGotoLabel(MapEvent.m_sMapName, MapEvent.m_nCurrX, MapEvent.m_nCurrY, MapEvent.m_nRange, MapEvent.m_MapFlag.nQuestUnit, MapEvent.m_MapFlag.boOpen,
                                MapEvent.m_Condition.sItemName, "*", MapEvent.m_Condition.boNeedGroup, MapEvent.m_nRandomCount))
                            {
                                boGotoLabel = true;
                                break;
                            }
                        }
                    }
                }
                if (boGotoLabel && (MapEvent != null))
                {
                    switch (MapEvent.m_StartScript.nLable)
                    {
                        case 0:
                            break;
                        case 1:
                            if (M2Share.g_FunctionNPC != null)
                            {
                                nCode = 6;
                                M2Share.g_FunctionNPC.GotoLable(this, MapEvent.m_StartScript.sLable, false);
                            }
                            break;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.StartMapEventOfMine Code:" + (nCode).ToString());
            }
        }

        /// <summary>
        /// 地图事件触发-走路
        /// </summary>
        public void StartMapEventOfWalk()
        {
            bool boGotoLabel;
            TMapEvent MapEvent;
            byte nCode = 0;
            try
            {
                nCode = 0;
                MapEvent = null;
                boGotoLabel = false;
                nCode = 1;
                if (M2Share.g_MapEventListOfWalk.Count > 0)
                {
                    nCode = 2;
                    for (int i = 0; i < M2Share.g_MapEventListOfWalk.Count; i++)
                    {
                        nCode = 3;
                        MapEvent = M2Share.g_MapEventListOfWalk[i];
                        nCode = 4;
                        if (MapEvent != null)
                        {
                            nCode = 5;
                            if (IsGotoLabel(MapEvent.m_sMapName, MapEvent.m_nCurrX, MapEvent.m_nCurrY, MapEvent.m_nRange, MapEvent.m_MapFlag.nQuestUnit, MapEvent.m_MapFlag.boOpen,
                                MapEvent.m_Condition.sItemName, "*", MapEvent.m_Condition.boNeedGroup, MapEvent.m_nRandomCount))
                            {
                                boGotoLabel = true;
                                break;
                            }
                        }
                    }
                }
                if (boGotoLabel && (MapEvent != null))
                {
                    switch (MapEvent.m_StartScript.nLable)
                    {
                        case 0:
                            break;
                        case 1:
                            if (M2Share.g_FunctionNPC != null)
                            {
                                nCode = 6;
                                M2Share.g_FunctionNPC.GotoLable(this, MapEvent.m_StartScript.sLable, false);
                            }
                            break;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.StartMapEventOfWalk nCode:" + (nCode).ToString());
            }
        }

        /// <summary>
        /// 地图事件触发-走
        /// </summary>
        public void StartMapEventOfRun()
        {
            bool boGotoLabel;
            TMapEvent MapEvent;
            byte nCode = 0;
            try
            {
                nCode = 0;
                MapEvent = null;
                boGotoLabel = false;
                nCode = 1;
                if (M2Share.g_MapEventListOfRun.Count > 0)
                {
                    nCode = 2;
                    for (int i = 0; i < M2Share.g_MapEventListOfRun.Count; i++)
                    {
                        nCode = 3;
                        MapEvent = M2Share.g_MapEventListOfRun[i];
                        nCode = 4;
                        if (MapEvent != null)
                        {
                            nCode = 5;
                            if (IsGotoLabel(MapEvent.m_sMapName, MapEvent.m_nCurrX, MapEvent.m_nCurrY, MapEvent.m_nRange, MapEvent.m_MapFlag.nQuestUnit, MapEvent.m_MapFlag.boOpen,
                                MapEvent.m_Condition.sItemName, "*", MapEvent.m_Condition.boNeedGroup, MapEvent.m_nRandomCount))
                            {
                                boGotoLabel = true;
                                break;
                            }
                        }
                    }
                }
                if (boGotoLabel && (MapEvent != null))
                {
                    switch (MapEvent.m_StartScript.nLable)
                    {
                        case 0:
                            break;
                        case 1:
                            if (M2Share.g_FunctionNPC != null)
                            {
                                nCode = 6;
                                M2Share.g_FunctionNPC.GotoLable(this, MapEvent.m_StartScript.sLable, false);
                            }
                            break;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.StartMapEventOfRun Code:" + (nCode).ToString());
            }
        }

        public void ProcessUserCmd(string sParam1, string sParam2, string sParam3, string sParam4, string sParam5, string sParam6, string sParam7)
        {
            this.SysMsg(sParam2, TMsgColor.c_Green, TMsgType.t_Hint);
        }

        // 增加祝福罐.魔令包功能
        public bool WearDragon()
        {
            bool result = false;
            TStdItem StdItem;
            if (this.m_UseItems[Grobal2.U_BUJUK].wIndex > 0)  // 修改成下面那段,以支持祝福罐.魔令包功
            {
                StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[Grobal2.U_BUJUK].wIndex);// 20080704 去掉除泉水罐外
                if ((StdItem != null) && (StdItem.StdMode == 2) && (StdItem.AniCount == 21))// 修改 StdItem.Shape=3  StdItem.Reserved=56为泉水罐
                {
                    result = true;// 祝福罐.魔令包
                }
            }
            return result;
        }

        /// <summary>
        /// 修补祝福罐.魔令包
        /// </summary>
        /// <param name="btType">2--主人  4--英雄</param>
        /// <param name="nItemIdx"></param>
        /// <param name="sItemName"></param>
        public void RepairDragon(byte btType, int nItemIdx, string sItemName)
        {
            int n14;
            TUserItem UserItem = null;
            TStdItem StdItem = null;
            TStdItem StdItem1 = null;
            string sUserItemName;
            bool boRepairOK;
            IList<TUserItem> ItemList;
            int OldDura;
            boRepairOK = false;
            ItemList = null;
            OldDura = 0;
            n14 = -1;
            if (WearDragon())
            {
                if (this.m_UseItems[Grobal2.U_BUJUK] != null && this.m_UseItems[Grobal2.U_BUJUK].Dura < this.m_UseItems[Grobal2.U_BUJUK].DuraMax)
                {
                    OldDura = this.m_UseItems[Grobal2.U_BUJUK].Dura;
                    switch (btType)
                    {
                        case 2:
                            ItemList = this.m_Master.m_ItemList;
                            break;
                        case 4:
                            ItemList = this.m_ItemList;
                            break;
                    }
                    if (ItemList != null)
                    {
                        if (ItemList.Count > 0)
                        {
                            for (int i = 0; i < ItemList.Count; i++)
                            {
                                UserItem = ItemList[i];
                                if ((UserItem != null) && (UserItem.MakeIndex == nItemIdx))
                                {
                                    // 取自定义物品名称
                                    sUserItemName = "";
                                    if (UserItem.btValue[13] == 1)
                                    {
                                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                    }
                                    if (sUserItemName == "")
                                    {
                                        sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                    }
                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                    if (StdItem != null)
                                    {
                                        if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                                        {
                                            n14 = i;
                                            StdItem1 = M2Share.UserEngine.GetStdItem(this.m_UseItems[Grobal2.U_BUJUK].wIndex);
                                            break;
                                        }
                                    }
                                }
                                UserItem = null;
                            }
                        }
                        // 存的物品的外观要对罐的Source属性,罐物品的Shape=放入物品的StdMode ,衣服武器不能存
                        if ((StdItem != null) && (UserItem != null) && (StdItem.Shape == StdItem1.Source) && (StdItem.StdMode == StdItem1.Shape) &&
                            (!(new ArrayList(new int[] { 5, 6, 10, 11 }).Contains(StdItem.StdMode))))
                        {
                            this.m_UseItems[Grobal2.U_BUJUK].Dura += 1000;
                            if (this.m_UseItems[Grobal2.U_BUJUK].Dura > this.m_UseItems[Grobal2.U_BUJUK].DuraMax)
                            {
                                this.m_UseItems[Grobal2.U_BUJUK].Dura = this.m_UseItems[Grobal2.U_BUJUK].DuraMax;
                            }
                            boRepairOK = true;
                            switch (btType)
                            {
                                case 2:
                                    this.m_Master.DelBagItem(n14);
                                    break;
                                case 4:
                                    this.DelBagItem(n14);
                                    break;
                            }
                        }
                    }
                }
            }
            if (boRepairOK)
            {
                if (OldDura != this.m_UseItems[Grobal2.U_BUJUK].Dura)
                {
                    this.SendMsg(this, Grobal2.RM_DURACHANGE, Grobal2.U_BUJUK, this.m_UseItems[Grobal2.U_BUJUK].Dura, this.m_UseItems[Grobal2.U_BUJUK].DuraMax, 0, "");
                }
                SendDefMessage(Grobal2.SM_REPAIRDRAGON_OK, btType, 0, 0, 0, "");
            }
            else
            {
                SendDefMessage(Grobal2.SM_REPAIRDRAGON_FAIL, btType, 0, 0, 0, "");
            }
        }

        // 取淬练列表物品
        public void GetBackRefineItem()
        {
            TClientItem ClientItem = null;
            TStdItem StdItem = null;
            TStdItem pStdItem = null;
            TUserItem UserItem = null;
            string sSENDMSG;
            string sUserItemName;
            sSENDMSG = "";
            if (m_RefineItemList.Count > 0)
            {
                for (int i = 0; i < m_RefineItemList.Count; i++)
                {
                    UserItem = m_RefineItemList[i];
                    if (UserItem.MakeIndex > 0)
                    {
                        this.m_ItemList.Add(UserItem);
                        pStdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                        if (pStdItem != null)
                        {
                            StdItem = pStdItem;
                            if (StdItem.NeedIdentify == 1)
                            {
                                M2Share.AddGameDataLog("41" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString()
                                    + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "("
                                    + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString()
                                    + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")"
                                    + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/"
                                    + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/"
                                    + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/"
                                    + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/"
                                    + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09" + (UserItem.Dura).ToString() + "/"
                                    + (UserItem.DuraMax).ToString());
                            }
                            M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem);
                            ClientItem.s = StdItem;
                            //Move(StdItem, ClientItem.s, sizeof(TStdItem));
                            // 取自定义物品名称
                            sUserItemName = "";
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (UserItem.btValue[12] == 1)
                            {
                                // 物品发光
                                ClientItem.s.Reserved1 = 1;
                            }
                            else
                            {
                                ClientItem.s.Reserved1 = 0;
                            }
                            if (sUserItemName != "")
                            {
                                ClientItem.s.Name = sUserItemName;
                            }
                            ClientItem.Dura = UserItem.Dura;
                            ClientItem.DuraMax = UserItem.DuraMax;
                            ClientItem.MakeIndex = UserItem.MakeIndex;
                            sSENDMSG = sSENDMSG + EncryptUnit.EncodeBuffer(ClientItem) + "/";
                        }
                    }
                }
            }
            this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_UPDATERYREFINEITEM, this.m_ActorsId, 0, 0, 0, 0);
            SendSocket(this.m_DefMsg, sSENDMSG);
            m_RefineItemList.Clear();
        }

        // 取备份淬练列表物品
        // 取淬练列表物品的名称
        public void GetBackRefineItemName(ref string sItemName, ref string sItemName1, ref string sItemName2)
        {
            TUserItem UserItem;
            TStdItem StdItem;
            string str;
            str = "";
            if (m_RefineItemList.Count > 0)
            {
                for (var i = 0; i < m_RefineItemList.Count; i++)
                {
                    UserItem = m_RefineItemList[i];
                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                    if (str != "")
                    {
                        str = str + "+";
                    }
                    if (StdItem != null)
                    {
                        str = str + StdItem.Name;
                    }
                }
            }
            if (str != "")
            {
                str = HUtil32.GetValidStr3(str, ref sItemName, new string[] { "+" });
                str = HUtil32.GetValidStr3(str, ref sItemName1, new string[] { "+" });
                str = HUtil32.GetValidStr3(str, ref sItemName2, new string[] { "+" });
            }
        }

        // 淬练过程
        public void ClientRefineItem()
        {
            ArrayList RefineItemList;
            TRefineItemInfo RefineItemInfo = new TRefineItemInfo();
            int addValue = 0, T = 0;
            TUserItem UserItem = null, UserItem1 = null, UserItem2 = null;
            TStdItem StdItem = null, StdItem1 = null;
            string sItemName = string.Empty, sItemName1 = string.Empty, sItemName2 = string.Empty;
            string str = string.Empty;
            bool boOK = false;
            try
            {
                if ((M2Share.g_RefineItemList == null) || (M2Share.g_RefineItemList.Count == 0))
                {
                    return;
                }
                if ((m_RefineItemList == null) || (m_RefineItemList.Count == 0))
                {
                    return;
                }
                GetBackRefineItemName(ref sItemName, ref sItemName1, ref sItemName2);// 取出粹练框中的物品名称
                RefineItemList = M2Share.GetRefineItemInfo(sItemName, sItemName1, sItemName2);// 取出对应配方的物品配置列表
                if (RefineItemList != null)
                {
                    if (RefineItemList.Count > 1)// 当淬炼原料下列表有多个物品，将随机抽取
                    {
                        for (int i = 0; i < RefineItemList.Count; i++)
                        {
                            T = HUtil32.Random(RefineItemList.Count);
                            RefineItemInfo = ((TRefineItemInfo)(RefineItemList[T]));
                            if (RefineItemInfo != null)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        RefineItemInfo = ((TRefineItemInfo)(RefineItemList[0])); // 不管成功以否,火云石都要掉持久或消失
                    }
                    if (RefineItemInfo.boDisappear)
                    {
                        // 掉持久
                        for (int i = m_RefineItemList.Count - 1; i >= 0; i--)
                        {
                            if (m_RefineItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = m_RefineItemList[i];
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if ((StdItem != null) && (StdItem.StdMode == 25) && ((StdItem.Shape == 10) || (StdItem.Shape == 11)))
                            {
                                if (UserItem.Dura >= 100)
                                {
                                    UserItem.Dura -= 100;// 掉持久
                                    if (UserItem.Dura <= 0)
                                    {
                                        m_RefineItemList.RemoveAt(i);
                                        UserItem = null;
                                    }
                                }
                                else
                                {
                                    m_RefineItemList.RemoveAt(i);
                                    UserItem = null;
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        // 消失
                        for (int i = m_RefineItemList.Count - 1; i >= 0; i--)
                        {
                            if (m_RefineItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = m_RefineItemList[i];
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if ((StdItem != null) && (StdItem.StdMode == 25) && ((StdItem.Shape == 10) || (StdItem.Shape == 11)))
                            {
                                m_RefineItemList.RemoveAt(i);
                                UserItem = null;
                                boOK = true;
                                break;
                            }
                        }
                    }
                    if ((HUtil32.Random(100) <= RefineItemInfo.nRefineRate)) // 淬练成功率
                    {
                        UserItem1 = new TUserItem();
                        if (M2Share.UserEngine.CopyToUserItemFromName(RefineItemInfo.sItemName, UserItem1))
                        {
                            var nAttribute = RefineItemInfo.TAttributeBuff;
                            for (int k = 0; k <= 13; k++)
                            {
                                if (nAttribute[k].nPoints == 0)
                                {
                                    continue;
                                }
                                // 最高限制升点数为零时,跳过
                                if (HUtil32.Random(nAttribute[k].nDifficult) == 0) // 淬炼难度
                                {
                                    addValue = nAttribute[k].nPoints - UserItem1.btValue[k];
                                    UserItem1.btValue[k] = nAttribute[k].nPoints;
                                }
                                else
                                {
                                    addValue = UserItem1.btValue[k];
                                    UserItem1.btValue[k] = Convert.ToByte(UserItem1.btValue[k] + HUtil32.Random(nAttribute[k].nPoints - 1) + 1);// 随机加点数 加1,防止随机值为0
                                    UserItem1.btValue[k] = Convert.ToByte(HUtil32._MIN(nAttribute[k].nPoints - 1, UserItem1.btValue[k]));
                                    addValue = UserItem1.btValue[k] - addValue;
                                }
                                if (addValue > 0)
                                {
                                    StdItem1 = M2Share.UserEngine.GetStdItem(UserItem1.wIndex);
                                    if (str != "")
                                    {
                                        str = str + " ";
                                    }
                                    switch (StdItem1.StdMode)
                                    {
                                        case 19:
                                            switch (k)
                                            {
                                                case 0:
                                                    str = str + " 魔法躲避增加" + addValue + "点";
                                                    break;
                                                case 1:
                                                    str = str + " 幸运增加" + addValue + "点";
                                                    break;
                                                case 2:
                                                    str = str + " 攻击增加" + addValue + "点";
                                                    break;
                                                case 3:
                                                    str = str + " 魔法增加" + addValue + "点";
                                                    break;
                                                case 4:
                                                    str = str + " 道术增加" + addValue + "点";
                                                    break;
                                                case 14:
                                                    str = str + " 持久增加" + addValue + "点";
                                                    break;
                                            }
                                            break;
                                        case 20:
                                        case 24:
                                            switch (k)
                                            {
                                                case 0:
                                                    str = str + " 准确增加" + addValue + "点";
                                                    break;
                                                case 1:
                                                    str = str + " 敏捷增加" + addValue + "点";
                                                    break;
                                                case 2:
                                                    str = str + " 攻击增加" + addValue + "点";
                                                    break;
                                                case 3:
                                                    str = str + " 魔法增加" + addValue + "点";
                                                    break;
                                                case 4:
                                                    str = str + " 道术增加" + addValue + "点";
                                                    break;
                                                case 14:
                                                    str = str + " 持久增加" + addValue + "点";
                                                    break;
                                            }
                                            break;
                                        case 21:
                                            switch (k)
                                            {
                                                case 0:
                                                    str = str + " 体力恢复增加" + addValue + "点";
                                                    break;
                                                case 1:
                                                    str = str + " 魔法恢复增加" + addValue + "点";
                                                    break;
                                                case 2:
                                                    str = str + " 攻击增加" + addValue + "点";
                                                    break;
                                                case 3:
                                                    str = str + " 魔法增加" + addValue + "点";
                                                    break;
                                                case 4:
                                                    str = str + " 道术增加" + addValue + "点";
                                                    break;
                                                case 14:
                                                    str = str + " 持久增加" + addValue + "点";
                                                    break;
                                            }
                                            break;
                                        case 23:
                                            switch (k)
                                            {
                                                case 0:
                                                    str = str + " 毒物躲避增加" + addValue + "点";
                                                    break;
                                                case 1:
                                                    str = str + " 中毒恢复增加" + addValue + "点";
                                                    break;
                                                case 2:
                                                    str = str + " 攻击增加" + addValue + "点";
                                                    break;
                                                case 3:
                                                    str = str + " 魔法增加" + addValue + "点";
                                                    break;
                                                case 4:
                                                    str = str + " 道术增加" + addValue + "点";
                                                    break;
                                                case 14:
                                                    str = str + " 持久增加" + addValue + "点";
                                                    break;
                                            }
                                            break;
                                        case 5:
                                        case 6:
                                            switch (k)
                                            {
                                                case 0:
                                                    str = str + " 攻击增加" + addValue + "点";
                                                    break;
                                                case 1:
                                                    str = str + " 魔法增加" + addValue + "点";
                                                    break;
                                                case 2:
                                                    str = str + " 道术增加" + addValue + "点";
                                                    break;
                                                case 3:
                                                    str = str + " 幸运增加" + addValue + "点";
                                                    break;
                                                case 4:
                                                    str = str + " 诅咒增加" + addValue + "点";
                                                    break;
                                                case 5:
                                                    str = str + " 准确增加" + addValue + "点";
                                                    break;
                                                case 6:
                                                    str = str + " 攻击速度增加" + addValue + "点";
                                                    break;
                                                case 7:
                                                    str = str + " 强度增加" + addValue + "点";
                                                    break;
                                                case 14:
                                                    str = str + " 持久增加" + addValue + "点";
                                                    break;
                                            }
                                            break;
                                        default:
                                            switch (k)
                                            {
                                                case 0:
                                                    str = str + " 防御增加" + addValue + "点";
                                                    break;
                                                case 1:
                                                    str = str + " 魔御增加" + addValue + "点";
                                                    break;
                                                case 2:
                                                    str = str + " 攻击增加" + addValue + "点";
                                                    break;
                                                case 3:
                                                    str = str + " 魔法增加" + addValue + "点";
                                                    break;
                                                case 4:
                                                    str = str + " 道术增加" + addValue + "点";
                                                    break;
                                                case 14:
                                                    str = str + " 持久增加" + addValue + "点";
                                                    break;
                                            }
                                            break;
                                    }
                                }
                            }
                            if ((HUtil32.Random(100) <= RefineItemInfo.nNeedRate))
                            {
                                M2Share.UserEngine.RandomUpgradeItem(UserItem1);
                            }
                            // 极品属性几率,附加极品属性
                            if (!boOK)
                            {
                                for (int i = m_RefineItemList.Count - 1; i >= 0; i--)
                                {
                                    // 在成功率内,则删除除火云石外的物品
                                    if (m_RefineItemList.Count <= 0)
                                    {
                                        break;
                                    }
                                    UserItem2 = m_RefineItemList[i];
                                    if ((UserItem2 != null) && (UserItem2.MakeIndex > 0))
                                    {
                                        StdItem1 = M2Share.UserEngine.GetStdItem(UserItem2.wIndex);
                                        if ((StdItem1 != null) && (StdItem1.StdMode != 25) && (StdItem1.Name != ""))
                                        {
                                            m_RefineItemList.RemoveAt(i);
                                            UserItem2 = null;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                m_RefineItemList.Clear();
                            }
                            m_RefineItemList.Add(UserItem1);// 物品保存到列表中
                            this.SysMsg(string.Format(GameMsgDef.sRefineItemSuccessMsg + str, RefineItemInfo.sItemName), TMsgColor.c_Green, TMsgType.t_Hint);// 成功提示
                        }
                    }
                    else
                    {
                        if ((HUtil32.Random(100) <= RefineItemInfo.nReductionRate)) // 失败后,在还原成功率内,则删除弩牌或封印装备
                        {
                            for (int i = m_RefineItemList.Count - 1; i >= 0; i--)// 修改
                            {
                                if (m_RefineItemList.Count <= 0)
                                {
                                    break;
                                }
                                UserItem = m_RefineItemList[i];
                                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if ((StdItem != null) && ((StdItem.StdMode == 47) || ("封印".IndexOf(StdItem.Name) > 0)))
                                {
                                    m_RefineItemList.RemoveAt(i);
                                    UserItem = null;
                                }
                            }
                        }
                        else
                        {
                            // 失败后,不在还原成功率内,1-合成新物品,则删除物品,除火去石外  2-升级物品,则初始属性
                            if (((RefineItemInfo.sItemName).ToLower().CompareTo((sItemName).ToLower()) == 0) || ((RefineItemInfo.sItemName).ToLower().CompareTo((sItemName1).ToLower()) == 0) || ((RefineItemInfo.sItemName).ToLower().CompareTo((sItemName2).ToLower()) == 0))
                            {
                                for (int i = m_RefineItemList.Count - 1; i >= 0; i--)
                                {
                                    if (m_RefineItemList.Count <= 0)
                                    {
                                        break;
                                    }
                                    UserItem = m_RefineItemList[i];
                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                    if ((StdItem != null))
                                    {
                                        if (((StdItem.Name).ToLower().CompareTo((RefineItemInfo.sItemName).ToLower()) == 0))
                                        {
                                            //m_RefineItemList.Delete(i);
                                            for (int K = 0; K <= 13; K++)
                                            {
                                                UserItem.btValue[K] = 0; // 初始属性
                                            }
                                            m_RefineItemList.Add(UserItem);
                                        }
                                        else if ((StdItem.StdMode != 25))
                                        {
                                            m_RefineItemList.RemoveAt(i);
                                            UserItem = null;
                                            UserItem = null;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int i = m_RefineItemList.Count - 1; i >= 0; i--)
                                {
                                    if (m_RefineItemList.Count <= 0)
                                    {
                                        break;
                                    }
                                    UserItem = m_RefineItemList[i];
                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                    if ((StdItem != null) && (StdItem.StdMode != 25))
                                    {
                                        m_RefineItemList.RemoveAt(i);
                                        UserItem = null;
                                    }
                                }
                            }
                        }
                        // '粹练装备失败!'
                        this.SysMsg(GameMsgDef.sRefineItemFailMsg, TMsgColor.c_Red, TMsgType.t_Hint);// 失败提示
                    }
                    GetBackRefineItem();// 发消息,更新粹练框中的物品
                }
                else
                {
                    if (m_RefineItemList.Count > 0)
                    {
                        for (int i = 0; i < m_RefineItemList.Count; i++)
                        {
                            UserItem = m_RefineItemList[i];
                            if (UserItem.MakeIndex > 0)
                            {
                                this.m_ItemList.Add(UserItem);
                            }
                        }
                    }
                    // '这次无法控制火云石的力量，淬炼失败了'
                    this.SysMsg(GameMsgDef.sRefineItemErrorMsg, TMsgColor.c_Red, TMsgType.t_Hint);// 物品不是配方里的物品,失败提示
                    m_RefineItemList.Clear();
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClientRefineItem");
            }
        }

        // 淬炼
        // ------------------------------------------------------------------------------
        public bool WearRefineItem()
        {
            bool result = false;
            TStdItem StdItem;
            if (this.m_UseItems[Grobal2.U_BUJUK] != null && this.m_UseItems[Grobal2.U_BUJUK].wIndex > 0)
            {
                StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[Grobal2.U_BUJUK].wIndex);
                if ((StdItem != null) && (StdItem.StdMode == 25) && (StdItem.Shape == 10))
                {
                    result = true;
                }
            }
            return result;
        }

        // 修补火云石
        public void RepairRefineItem(int nItemIdx, string sItemName)
        {
            int n14;
            TUserItem UserItem = null;
            TStdItem StdItem;
            string sUserItemName;
            bool boRepairOK;
            int OldDura;
            boRepairOK = false;
            StdItem = null;
            OldDura = 0;
            n14 = -1;
            if (WearRefineItem())
            {
                if ((this.m_UseItems[Grobal2.U_BUJUK].Dura < this.m_UseItems[Grobal2.U_BUJUK].DuraMax) && (this.m_UseItems[Grobal2.U_BUJUK].Dura >= 500))
                {
                    OldDura = this.m_UseItems[Grobal2.U_BUJUK].Dura;
                    if (this.m_ItemList.Count > 0)
                    {
                        for (var i = 0; i < this.m_ItemList.Count; i++)
                        {
                            UserItem = this.m_ItemList[i];
                            if ((UserItem != null) && (UserItem.MakeIndex == nItemIdx))
                            {
                                // 取自定义物品名称
                                sUserItemName = "";
                                if (UserItem.btValue[13] == 1)
                                {
                                    sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                }
                                if (sUserItemName == "")
                                {
                                    sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                }
                                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if (StdItem != null)
                                {
                                    if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                                    {
                                        n14 = i;
                                        break;
                                    }
                                }
                            }
                        }
                        if ((StdItem != null) && (UserItem != null) && (StdItem.StdMode == 43) && (StdItem.Shape == 1))
                        {
                            this.m_UseItems[Grobal2.U_BUJUK].Dura += 500;
                            if (this.m_UseItems[Grobal2.U_BUJUK].Dura > this.m_UseItems[Grobal2.U_BUJUK].DuraMax)
                            {
                                this.m_UseItems[Grobal2.U_BUJUK].Dura = this.m_UseItems[Grobal2.U_BUJUK].DuraMax;
                            }
                            boRepairOK = true;
                            this.DelBagItem(n14);
                        }
                    }
                }
            }
            if (boRepairOK)
            {
                if (OldDura != this.m_UseItems[Grobal2.U_BUJUK].Dura)
                {
                    this.SendMsg(this, Grobal2.RM_DURACHANGE, Grobal2.U_BUJUK, this.m_UseItems[Grobal2.U_BUJUK].Dura, this.m_UseItems[Grobal2.U_BUJUK].DuraMax, 0, "");
                }
                SendDefMessage(Grobal2.SM_REPAIRFINEITEM_OK, 0, 0, 0, 0, "");
            }
            else
            {
                SendDefMessage(Grobal2.SM_REPAIRFINEITEM_FAIL, 0, 0, 0, 0, "");
                this.SysMsg("修补火云石失败!", TMsgColor.BB_Fuchsia, TMsgType.t_Hint);
            }
        }

        // 读取师徒文件
        public bool GetMasterNoList()
        {
            bool result = false;
            TStringList LoadList;
            string sFileName;
            string s01 = string.Empty;
            string s02 = string.Empty;
            string s03 = string.Empty;
            TMasterList TMasterList;
            try
            {
                sFileName = M2Share.g_Config.sEnvirDir + "MasterNo";
                if (!Directory.Exists(sFileName))
                {
                    Directory.CreateDirectory(sFileName);
                }
                // 目录不存在,则创建
                if (m_sMasterName != "")
                {
                    // 有师傅,取排名
                    sFileName = sFileName + "\\" + m_sMasterName + ".txt";
                    LoadList = new TStringList();
                    if (File.Exists(sFileName))
                    {
                        LoadList.LoadFromFile(sFileName);
                        if (LoadList.Count > 0)
                        {
                            for (var i = 0; i < LoadList.Count; i++)
                            {
                                s01 = LoadList[i].Trim();
                                if ((s01 != "") && (s01[1] != ';'))
                                {
                                    s01 = HUtil32.GetValidStr3(s01, ref s02, new string[] { " ", "\09" });// 徒弟名
                                    s01 = HUtil32.GetValidStr3(s01, ref s03, new string[] { " ", "\09" });// 排行
                                    if (s02 != "")
                                    {
                                        if ((this.m_sCharName).ToLower().CompareTo((s02).ToLower()) == 0)
                                        {
                                            // m_nMasterNo = HUtil32.Str_ToInt(s03, 0);
                                            result = true;
                                            break;
                                        }
                                    }
                                }
                                // if (s01 <> '') and (s01[1] <> ';') then begin
                            }
                            // for
                        }
                    }
                    // if FileExists(sFileName)

                    Dispose(LoadList);
                }
                else if (m_boMaster)
                {
                    // 有徒弟,取列表内容
                    sFileName = sFileName + "\\" + this.m_sCharName + ".txt";
                    LoadList = new TStringList();
                    if (File.Exists(sFileName))
                    {
                        LoadList.LoadFromFile(sFileName);
                        if (LoadList.Count > 0)
                        {
                            for (var i = 0; i < LoadList.Count; i++)
                            {
                                s01 = LoadList[i].Trim();
                                if ((s01 != "") && (s01[0] != ';'))
                                {
                                    s01 = HUtil32.GetValidStr3(s01, ref s02, new string[] { " ", "\09" });// 徒弟名
                                    s01 = HUtil32.GetValidStr3(s01, ref s03, new string[] { " ", "\09" });// 排行
                                    if (s02 != "")
                                    {
                                        TMasterList = new TMasterList
                                        {
                                            ID = Convert.ToInt32(s03),
                                            sChrName = s02
                                        };
                                        // m_MasterNoList.Add(s03, ((TMasterList) as Object));
                                    }
                                }
                            }
                        }
                        result = true;
                    }
                    Dispose(LoadList);
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.GetMasterNoList");
            }
            return result;
        }

        // 保存师徒文件
        public void SaveMasterNoList()
        {
            
            TStringList SaveList;
            string sFileName;
            TMasterList TMasterList = null;
            try
            {
                sFileName = M2Share.g_Config.sEnvirDir + "MasterNo";
                if (!Directory.Exists(sFileName))
                {
                    Directory.CreateDirectory(sFileName);
                }
                // 目录不存在,则创建
                if (m_boMaster)
                {
                    // 有徒弟才能保存列表
                    sFileName = sFileName + "\\" + this.m_sCharName + ".txt";
                    SaveList = new TStringList();
                    MasterNoListQuickSort(m_MasterNoList, true);// 排序
                    if (m_MasterNoList.Count > 0)
                    {
                        for (var i = 0; i < m_MasterNoList.Count; i++)
                        {
                            //TMasterList = ((TMasterList)(m_MasterNoList[i]));
                            //SaveList.Add(TMasterList.sChrName + " " + (TMasterList.ID).ToString());
                        }
                    }
                    SaveList.SaveToFile(sFileName);
                    SaveList.Dispose();
                    Dispose(SaveList);
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.SaveMasterNoList");
            }
        }

        // 收徒
        public void AddMaster(string MasterName)
        {
            TMasterList TMasterList;
            TMasterList = new TMasterList
            {
                sChrName = MasterName,
                ID = m_MasterNoList.Count + 1
            };
            //m_MasterNoList.Add((TMasterList.ID).ToString(), ((TMasterList) as Object));
            SaveMasterNoList();
            // 保存师徒文件 20080530
        }

        // 出师
        public void DelMaster(string MasterName)
        {
            TMasterList TMasterList = null;
            for (var i = m_MasterNoList.Count - 1; i >= 0; i--)
            {
                if (m_MasterNoList.Count <= 0)
                {
                    break;
                }
                // TMasterList = ((TMasterList)(m_MasterNoList[i]));
                if ((TMasterList.sChrName.Trim()).ToLower().CompareTo((MasterName.Trim()).ToLower()) == 0)
                {
                    Dispose(TMasterList);
                    m_MasterNoList.RemoveAt(i);
                    break;
                }
            }
            SaveMasterNoList();// 保存师徒文件
        }

        public void MasterNoListQuickSort_QuickSortStrListCase(List<string> List, int l, int r, bool Order)
        {
            int j;
            int i;
            string p;
            if (List.Count <= 0)
            {
                return;
            }
            do
            {
                i = l;
                j = r;
                p = List[(l + r) >> 1];
                do
                {
                    if (Order)
                    {
                        // 升序
                        while (List[i].CompareTo(p) < 0)
                        {
                            i++;
                        }
                        while (List[j].CompareTo(p) > 0)
                        {
                            j -= 1;
                        }
                    }
                    else
                    {
                        // 降序
                        while (p.CompareTo(List[i]) < 0)
                        {
                            i++;
                        }
                        while (p.CompareTo(List[j]) > 0)
                        {
                            j -= 1;
                        }
                    }
                    if (i <= j)
                    {
                        // List.Exchange(i, j);
                        i++;
                        j -= 1;
                    }
                } while (!(i > j));
                if (l < j)
                {
                    MasterNoListQuickSort_QuickSortStrListCase(List, l, j, Order);
                }
                l = i;
            } while (!(i >= r));
        }

        public void MasterNoListQuickSort_AddList(List<string> TempList, string slen, string s, Object AObject)
        {
            //
            //List<string> List;
            //bool boFound;
            //boFound = false;
            //if (TempList.Count > 0)
            //{
            //    for (var i = 0; i < TempList.Count; i++)
            //    {
            //        if ((TempList[i]).ToLower().CompareTo((slen).ToLower()) == 0)
            //        {
            //            List = ((TempList.Values[i]) as List<string>);
            //            List.Add(s, AObject);
            //            boFound = true;
            //            break;
            //        }
            //    }
            //}
            //if (!boFound)
            //{
            //    List = new List<string>();
            //    List.Add(s, AObject);
            //    TempList.Add(slen, List);
            //}
        }

        // 师徒数据排序  (用于徒弟出师,收徒后进行排名的排序)
        public void MasterNoListQuickSort(List<string> sList, bool Order)
        {
            List<string> TempList;
            List<string> List = null;
            
            int nLen;
            TMasterList TMasterList;
            TempList = new List<string>();
            if (sList.Count > 0)
            {
                for (var i = 0; i < sList.Count; i++)
                {
                    nLen = sList[i].Length;
                    // sList.Strings[i]
                    MasterNoListQuickSort_AddList(TempList, (nLen).ToString(), (i + 1).ToString(), sList[i]);
                }
            }
            MasterNoListQuickSort_QuickSortStrListCase(TempList, 0, TempList.Count - 1, Order);
            sList.Clear();
            if (TempList.Count > 0)
            {
                for (var i = 0; i < TempList.Count; i++)
                {
                    //List = ((TempList[i]) as List<string>);
                    MasterNoListQuickSort_QuickSortStrListCase(List, 0, List.Count - 1, Order);
                    //sList.Add(List);
                    Dispose(List);
                }
            }
            Dispose(TempList);
            if (m_MasterNoList.Count > 0)
            {
                for (var i = 0; i < m_MasterNoList.Count; i++)
                {
                    //TMasterList = ((TMasterList)(m_MasterNoList[i]));
                    //TMasterList.ID = i + 1;
                }
            }
        }

        public int ClientPlayMakeWine_GetRandomRange(int nCount, int nRate)
        {
            int result;
            
            result = 0;
            if (nCount <= 0)
            {
                return result;
            }
            for (var i = 0; i < nCount; i++)
            {
                if (HUtil32.Random(nRate) == 0)
                {
                    result++;
                }
            }
            return result;
        }

        // --------------------------酿酒系统-------------------------------------------
        /// <summary>
        /// 客户端开始酿酒
        /// </summary>
        /// <param name="nCode">0-普通 1-药酒</param>
        /// <param name="sMsg">NPC标识</param>
        public void ClientPlayMakeWine(byte nCode, string sMsg)
        {
            int nItemId;
            int nItemId1;
            int nItemId2;
            int nItemId3;
            int nItemId4;
            int nItemId5;
            int nItemId6;
            string Str = string.Empty;
            string Str1 = string.Empty;
            string Str2 = string.Empty;
            string Str3 = string.Empty;
            string Str4 = string.Empty;
            string Str5 = string.Empty;
            string Str6 = string.Empty;
            TStdItem StdItem = null;
            TStdItem StdItem1 = null;
            TStdItem StdItem2 = null;
            TStdItem StdItem3 = null;
            TStdItem StdItem4 = null;
            TStdItem StdItem5 = null;
            TStdItem StdItem6 = null;
            TUserItem UserItem;
            int nC;
            bool boMakeWine;
            bool boMakeWineOK;
            byte Check;
            boMakeWine = false;
            boMakeWineOK = false;
            Check = 0;
            try
            {
                if ((new ArrayList(new int[] { 0, 1 }).Contains(nCode)) && (sMsg != "") && !m_boMakeWine)
                {
                    switch (nCode)
                    {
                        case 0:// 普通酒
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str, new string[] { "/", "\09" });
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str1, new string[] { "/", "\09" });
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str2, new string[] { "/", "\09" });
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str3, new string[] { "/", "\09" });
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str4, new string[] { "/", "\09" });
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str5, new string[] { "/", "\09" });
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str6, new string[] { "/", "\09" });
                            nItemId = HUtil32.Str_ToInt(Str, 0);// 主材料
                            nItemId1 = HUtil32.Str_ToInt(Str1, 0);// 酒曲
                            nItemId2 = HUtil32.Str_ToInt(Str2, 0);// 水
                            nItemId3 = HUtil32.Str_ToInt(Str3, 0);// 酒坛
                            nItemId4 = HUtil32.Str_ToInt(Str4, 0);// 辅助材料1
                            nItemId5 = HUtil32.Str_ToInt(Str5, 0);// 辅助材料2
                            nItemId6 = HUtil32.Str_ToInt(Str6, 0);// 辅助材料3
                            Check = 1;
                            if (this.m_ItemList.Count > 0)
                            {
                                for (var i = 0; i < this.m_ItemList.Count; i++)
                                {
                                    Check = 2;
                                    UserItem = this.m_ItemList[i];
                                    Check = 3;
                                    if (UserItem != null)
                                    {
                                        if (UserItem.MakeIndex == nItemId)
                                        {
                                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                        else if (UserItem.MakeIndex == nItemId1)
                                        {
                                            StdItem1 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                        else if (UserItem.MakeIndex == nItemId2)
                                        {
                                            StdItem2 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                        else if (UserItem.MakeIndex == nItemId3)
                                        {
                                            StdItem3 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                        else if (UserItem.MakeIndex == nItemId4)
                                        {
                                            StdItem4 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                        else if (UserItem.MakeIndex == nItemId5)
                                        {
                                            StdItem5 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                        else if (UserItem.MakeIndex == nItemId6)
                                        {
                                            StdItem6 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                    }
                                }
                            }
                            Check = 4;
                            if ((StdItem != null) && (StdItem2 != null) && (StdItem3 != null) && (StdItem4 != null) && (StdItem5 != null) && (StdItem6 != null))
                            {
                                Check = 5;
                                if ((StdItem.StdMode == 8) && (StdItem2.StdMode == 9) && ((StdItem3.StdMode == 12) && (StdItem3.Shape == 0))
                                    && (StdItem4.StdMode == 8) && (StdItem5.StdMode == 8) && (StdItem6.StdMode == 8))
                                {
                                    n_MakeWineQuality = (byte)StdItem.AC;
                                    // 主料的品质值
                                    if (StdItem2.Shape == 1)
                                    {
                                        n_MakeWineQuality = Convert.ToByte(n_MakeWineQuality + 1);// 使用泉水品质+1
                                    }
                                    Check = 6;
                                    m_boMakeWine = true;// 是否酿酒
                                    m_MakeWineTime = M2Share.g_Config.nMakeWineTime;// 酿酒等待的时间
                                    n_MakeWineItmeType = StdItem.AniCount;// 酿酒后,应该可以得到酒的类型
                                    n_MakeWineType = 1;// 酿酒的类型 1-普通酒 2-药酒
                                    if (StdItem1 != null)
                                    {
                                        // 判断酒曲是否是与主材料对应,对应则加品质+1
                                        if ((StdItem1.Shape == StdItem.AniCount) && (HUtil32.Random(3) == 0))
                                        {
                                            n_MakeWineQuality = Convert.ToByte(n_MakeWineQuality + 1);
                                        }
                                    }
                                    if (StdItem.Source == 1)
                                    {
                                        // 精制材料可以得到酒的品质
                                        nC = ClientPlayMakeWine_GetRandomRange(3, 5);
                                        n_MakeWineQuality = Convert.ToByte(n_MakeWineQuality + nC);
                                        if (n_MakeWineQuality > 10)
                                        {
                                            n_MakeWineQuality = 10;
                                        }
                                    }
                                    else
                                    {
                                        nC = ClientPlayMakeWine_GetRandomRange(3, 4); // 普通材料
                                        n_MakeWineQuality = Convert.ToByte(n_MakeWineQuality + nC);// 可以得到酒的品质
                                        if (n_MakeWineQuality > 5)
                                        {
                                            n_MakeWineQuality = 5;
                                        }
                                    }
                                    if (n_MakeWineQuality == 0)
                                    {
                                        n_MakeWineQuality = 1;
                                    }
                                    n_MakeWineAlcohol = Convert.ToByte(StdItem.Reserved + StdItem4.Reserved + HUtil32.Random(StdItem5.Reserved)
                                        + HUtil32.Random(StdItem6.Reserved));// 可以得到酒的酒精度
                                    if (n_MakeWineAlcohol > 100)
                                    {
                                        n_MakeWineAlcohol = Convert.ToByte(HUtil32.Random(30) + 30);
                                    }
                                    boMakeWine = true;
                                    Check = 7;
                                }
                            }
                            if (boMakeWine)
                            {
                                for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
                                {
                                    if (this.m_ItemList.Count <= 0)
                                    {
                                        break;
                                    }
                                    Check = 8;
                                    UserItem = this.m_ItemList[i];
                                    Check = 9;
                                    if (UserItem != null)
                                    {
                                        if ((UserItem.MakeIndex == nItemId) || (UserItem.MakeIndex == nItemId1) || (UserItem.MakeIndex == nItemId2) || (UserItem.MakeIndex == nItemId3)
                                            || (UserItem.MakeIndex == nItemId4) || (UserItem.MakeIndex == nItemId5) || (UserItem.MakeIndex == nItemId6))
                                        {
                                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                            if (StdItem != null)
                                            {
                                                Check = 10;
                                                SendDelItems(UserItem);
                                                Check = 11;
                                                UserItem = null;
                                                Check = 12;
                                                this.m_ItemList.RemoveAt(i);
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case 1:// 药酒
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str, new string[] { "/", "\09" });
                            sMsg = HUtil32.GetValidStr3(sMsg, ref Str1, new string[] { "/", "\09" });
                            nItemId = HUtil32.Str_ToInt(Str, 0);// 药材
                            nItemId1 = HUtil32.Str_ToInt(Str1, 0);// 酒
                            nItemId2 = HUtil32.Str_ToInt(sMsg, 0);// 酒瓶
                            if (this.m_ItemList.Count > 0)
                            {
                                for (var i = 0; i < this.m_ItemList.Count; i++)
                                {
                                    UserItem = this.m_ItemList[i];
                                    if (UserItem != null)
                                    {
                                        if (UserItem.MakeIndex == nItemId)
                                        {
                                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                        else if (UserItem.MakeIndex == nItemId1)
                                        {
                                            StdItem1 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                            if ((StdItem1.StdMode == 60) && (StdItem1.Shape != 0))// 普通酒
                                            {
                                                if ((UserItem.btValue[0] > 5) &&
                                                    (UserItem.Dura == UserItem.DuraMax))// 普通酒品质达6以上,并且没喝过,才做酿造药酒
                                                {
                                                    boMakeWineOK = true;
                                                    n_MakeWineQuality = UserItem.btValue[0];// 可以得到酒的品质
                                                    n_MakeWineAlcohol = UserItem.btValue[1];// 可以得到酒的酒精度
                                                    if (n_MakeWineAlcohol > 100)
                                                    {
                                                        n_MakeWineAlcohol = Convert.ToByte(HUtil32.Random(30) + 30);
                                                    }
                                                }
                                            }
                                        }
                                        else if (UserItem.MakeIndex == nItemId2)
                                        {
                                            StdItem2 = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        }
                                    }
                                }
                            }
                            if ((StdItem != null) && (StdItem1 != null) && (StdItem2 != null))
                            {
                                if ((StdItem.StdMode == 14) && boMakeWineOK && ((StdItem2.StdMode == 12) && (StdItem2.Shape == 1)))
                                {
                                    m_boMakeWine = true;// 是否酿酒
                                    m_MakeWineTime = (UInt16)M2Share.g_Config.nMakeWineTime1;// 酿药酒等待的时间
                                    n_MakeWineItmeType = StdItem.AniCount;// 酿酒后,应该可以得到酒的类型
                                    n_MakeWineType = 2;// 酿酒的类型 1-普通酒 2-药酒
                                    boMakeWine = true;//酿造成功
                                }
                            }
                            if (!boMakeWine)
                            {
                                n_MakeWineQuality = 0;// 可以得到酒的品质
                                n_MakeWineAlcohol = 0;// 可以得到酒的酒精度
                            }
                            else
                            {
                                for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
                                {
                                    if (this.m_ItemList.Count <= 0)
                                    {
                                        break;
                                    }
                                    Check = 18;
                                    UserItem = this.m_ItemList[i];
                                    Check = 19;
                                    if (UserItem != null)
                                    {
                                        if ((UserItem.MakeIndex == nItemId) || (UserItem.MakeIndex == nItemId1) || (UserItem.MakeIndex == nItemId2))
                                        {
                                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                            if (StdItem != null)
                                            {
                                                Check = 20;
                                                SendDelItems(UserItem);
                                                Check = 21;
                                                UserItem = null;
                                                Check = 22;
                                                this.m_ItemList.RemoveAt(i);
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                    }
                }
                // 材料全对应上后,提示玩家开始酿造,需等待一会,并发个消息给客户端把窗口关掉
                if (boMakeWine)// 酿造成功
                {
                    this.SendMsg(this, Grobal2.RM_MAKEWINE_OK, 0, nCode, 0, 0, "");// 酿造成功
                    if (M2Share.g_FunctionNPC != null)
                    {
                        M2Share.g_FunctionNPC.GotoLable(this, "@BeginMakeWine", false);// 酿造成功
                    }
                }
                else // 酿酒失败
                {
                    this.SendMsg(this, Grobal2.RM_MAKEWINE_FAIL, 0, nCode, 0, 0, "");// 酿造失败
                    if (m_boMakeWine) // 已经有酒在酿中
                    {
                        if (M2Share.g_FunctionNPC != null)
                        {
                            M2Share.g_FunctionNPC.GotoLable(this, "@MakeWineFail", false);// 酿造失败
                        }
                    }
                    else
                    {
                        if (M2Share.g_FunctionNPC != null)
                        {
                            M2Share.g_FunctionNPC.GotoLable(this, "@MakeWineFail1", false);// 酿造失败
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClientPlayMakeWine Code:" + (Check).ToString());
            }
        }

        // -----------------------------------------------------------------------------
        // 先判断玩家毒符位是否有泉水罐,然后判断是否在泉眼上,最后记时,到时间加泉水
        private void PlayGatherFountain()
        {
            if ((this.m_UseItems[Grobal2.U_BUJUK] != null) && (this.m_UseItems[Grobal2.U_BUJUK].wIndex > 0)
                && (this.m_UseItems[Grobal2.U_BUJUK].Dura != this.m_UseItems[Grobal2.U_BUJUK].DuraMax))
            {
                TStdItem StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[Grobal2.U_BUJUK].wIndex);
                if (StdItem != null)
                {
                    if ((StdItem.StdMode == 2) && (StdItem.AniCount == 21) && (StdItem.Reserved == 56)) // 有泉水罐
                    {
                        if (M2Share.g_EventManager.GetEvent(this.m_PEnvir, this.m_nCurrX, this.m_nCurrY, Grobal2.ET_FOUNTAIN) != null) // 判断玩家是在泉眼上
                        {
                            n_InFountainTime++;// 累积站在泉眼上的时间
                            if (n_InFountainTime >= M2Share.g_Config.nInFountainTime) // 达到累积时间,则增加泉水罐的持久
                            {
                                this.m_UseItems[Grobal2.U_BUJUK].Dura += 100;
                                if (this.m_MyGuild != null)
                                {
                                    this.m_MyGuild.boChanged = true;
                                    this.m_MyGuild.m_nGuildFountain++;// 累积行会泉水
                                }
                                if (this.m_UseItems[Grobal2.U_BUJUK].Dura > this.m_UseItems[Grobal2.U_BUJUK].DuraMax)
                                {
                                    this.m_UseItems[Grobal2.U_BUJUK].Dura = this.m_UseItems[Grobal2.U_BUJUK].DuraMax;
                                }
                                this.SendMsg(this, Grobal2.RM_DURACHANGE, Grobal2.U_BUJUK, this.m_UseItems[Grobal2.U_BUJUK].Dura, this.m_UseItems[Grobal2.U_BUJUK].DuraMax, 0, "");
                                this.SendRefMsg(Grobal2.RM_MYSHOW, 10, 0, 0, 0, "");// 采集到泉水动画
                                n_InFountainTime = 0;
                            }
                        }
                        else
                        {
                            n_InFountainTime = 0;
                        }
                    }
                }
            }
            else if (n_InFountainTime != 0)
            {
                n_InFountainTime = 0;
            }
        }

        /// <summary>
        /// 气血石功能
        /// </summary>
        private void PlaySuperRock()
        {
            int nTempDura;
            try
            {
                if ((!this.m_boDeath) && (!this.m_boGhost) && (this.m_WAbil.HP > 0))
                {
                    if ((this.m_UseItems[Grobal2.U_CHARM] != null) && (this.m_UseItems[Grobal2.U_CHARM].wIndex > 0) && (this.m_UseItems[Grobal2.U_CHARM].Dura > 0))
                    {
                        TStdItem StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[Grobal2.U_CHARM].wIndex);
                        if ((StdItem != null))
                        {
                            if ((StdItem.Shape > 0) && this.m_PEnvir.AllowStdItems(StdItem.Name))
                            {
                                switch (StdItem.Shape)
                                {
                                    case 1:// 气血石
                                        if ((this.m_WAbil.MaxHP - this.m_WAbil.HP) >= M2Share.g_Config.nStartHPRock) // 改成掉点数启用
                                        {
                                            if (HUtil32.GetTickCount() - dwRockAddHPTick > M2Share.g_Config.nHPRockSpell)
                                            {
                                                dwRockAddHPTick = HUtil32.GetTickCount();// 气石加HP间隔
                                                if (this.m_UseItems[Grobal2.U_CHARM].Dura * 10 > M2Share.g_Config.nHPRockDecDura)
                                                {
                                                    this.m_WAbil.HP += M2Share.g_Config.nRockAddHP;
                                                    nTempDura = this.m_UseItems[Grobal2.U_CHARM].Dura * 10;
                                                    nTempDura -= M2Share.g_Config.nHPRockDecDura;
                                                    this.m_UseItems[Grobal2.U_CHARM].Dura = (ushort)HUtil32.Round((double)nTempDura / 10);
                                                    if (this.m_UseItems[Grobal2.U_CHARM].Dura > 0)
                                                    {
                                                        this.SendMsg(this, Grobal2.RM_DURACHANGE, Grobal2.U_CHARM, this.m_UseItems[Grobal2.U_CHARM].Dura, this.m_UseItems[Grobal2.U_CHARM].DuraMax, 0, "");
                                                    }
                                                    else
                                                    {
                                                        SendDelItems(this.m_UseItems[Grobal2.U_CHARM]);
                                                        this.m_UseItems[Grobal2.U_CHARM].wIndex = 0;
                                                    }
                                                }
                                                else
                                                {
                                                    this.m_WAbil.HP += M2Share.g_Config.nRockAddHP;
                                                    this.m_UseItems[Grobal2.U_CHARM].Dura = 0;
                                                    SendDelItems(this.m_UseItems[Grobal2.U_CHARM]);
                                                    this.m_UseItems[Grobal2.U_CHARM].wIndex = 0;
                                                }
                                                if (this.m_WAbil.HP > this.m_WAbil.MaxHP)
                                                {
                                                    this.m_WAbil.HP = this.m_WAbil.MaxHP;
                                                }
                                                this.PlugHealthSpellChanged();
                                            }
                                        }
                                        break;
                                    case 2:
                                        if ((this.m_WAbil.MaxMP - this.m_WAbil.MP) >= M2Share.g_Config.nStartMPRock)// 改成掉点数启用
                                        {
                                            if (HUtil32.GetTickCount() - dwRockAddMPTick > M2Share.g_Config.nMPRockSpell)
                                            {
                                                dwRockAddMPTick = HUtil32.GetTickCount();// 气石加MP间隔
                                                if (this.m_UseItems[Grobal2.U_CHARM].Dura * 10 > M2Share.g_Config.nMPRockDecDura)
                                                {
                                                    this.m_WAbil.MP += M2Share.g_Config.nRockAddMP;
                                                    nTempDura = this.m_UseItems[Grobal2.U_CHARM].Dura * 10;
                                                    nTempDura -= M2Share.g_Config.nMPRockDecDura;
                                                    this.m_UseItems[Grobal2.U_CHARM].Dura = (ushort)HUtil32.Round((double)nTempDura / 10);
                                                    if (this.m_UseItems[Grobal2.U_CHARM].Dura > 0)
                                                    {
                                                        this.SendMsg(this, Grobal2.RM_DURACHANGE, Grobal2.U_CHARM, this.m_UseItems[Grobal2.U_CHARM].Dura, this.m_UseItems[Grobal2.U_CHARM].DuraMax, 0, "");
                                                    }
                                                    else
                                                    {
                                                        SendDelItems(this.m_UseItems[Grobal2.U_CHARM]);
                                                        this.m_UseItems[Grobal2.U_CHARM].wIndex = 0;
                                                    }
                                                }
                                                else
                                                {
                                                    this.m_WAbil.MP += M2Share.g_Config.nRockAddMP;
                                                    this.m_UseItems[Grobal2.U_CHARM].Dura = 0;
                                                    SendDelItems(this.m_UseItems[Grobal2.U_CHARM]);
                                                    this.m_UseItems[Grobal2.U_CHARM].wIndex = 0;
                                                }
                                                if (this.m_WAbil.MP > this.m_WAbil.MaxMP)
                                                {
                                                    this.m_WAbil.MP = this.m_WAbil.MaxMP;
                                                }
                                                this.PlugHealthSpellChanged();
                                            }
                                        }
                                        break;
                                    case 3:
                                        if ((this.m_WAbil.MaxHP - this.m_WAbil.HP) >= M2Share.g_Config.nStartHPMPRock)// 改成掉点数启用
                                        {
                                            if (HUtil32.GetTickCount() - dwRockAddHPTick > M2Share.g_Config.nHPMPRockSpell)
                                            {
                                                dwRockAddHPTick = HUtil32.GetTickCount();// 气石加HP间隔
                                                if (this.m_UseItems[Grobal2.U_CHARM].Dura * 10 > M2Share.g_Config.nHPMPRockDecDura)
                                                {
                                                    this.m_WAbil.HP += M2Share.g_Config.nRockAddHPMP;
                                                    nTempDura = this.m_UseItems[Grobal2.U_CHARM].Dura * 10;
                                                    nTempDura -= M2Share.g_Config.nHPMPRockDecDura;
                                                    this.m_UseItems[Grobal2.U_CHARM].Dura = (ushort)HUtil32.Round((double)nTempDura / 10);
                                                    if (this.m_UseItems[Grobal2.U_CHARM].Dura > 0)
                                                    {
                                                        this.SendMsg(this, Grobal2.RM_DURACHANGE, Grobal2.U_CHARM, this.m_UseItems[Grobal2.U_CHARM].Dura, this.m_UseItems[Grobal2.U_CHARM].DuraMax, 0, "");
                                                    }
                                                    else
                                                    {
                                                        SendDelItems(this.m_UseItems[Grobal2.U_CHARM]);
                                                        this.m_UseItems[Grobal2.U_CHARM].wIndex = 0;
                                                    }
                                                }
                                                else
                                                {
                                                    this.m_WAbil.HP += M2Share.g_Config.nRockAddHPMP;
                                                    this.m_UseItems[Grobal2.U_CHARM].Dura = 0;
                                                    SendDelItems(this.m_UseItems[Grobal2.U_CHARM]);
                                                    this.m_UseItems[Grobal2.U_CHARM].wIndex = 0;
                                                }
                                                if (this.m_WAbil.HP > this.m_WAbil.MaxHP)
                                                {
                                                    this.m_WAbil.HP = this.m_WAbil.MaxHP;
                                                }
                                                this.PlugHealthSpellChanged();
                                            }
                                        }
                                        // ======================================================================
                                        if ((this.m_WAbil.MaxMP - this.m_WAbil.MP) >= M2Share.g_Config.nStartHPMPRock)// 改成掉点数启用
                                        {
                                            if (HUtil32.GetTickCount() - dwRockAddMPTick > M2Share.g_Config.nHPMPRockSpell)
                                            {
                                                dwRockAddMPTick = HUtil32.GetTickCount();// 气石加MP间隔
                                                if (this.m_UseItems[Grobal2.U_CHARM].Dura * 10 > M2Share.g_Config.nHPMPRockDecDura)
                                                {
                                                    this.m_WAbil.MP += M2Share.g_Config.nRockAddHPMP;
                                                    nTempDura = this.m_UseItems[Grobal2.U_CHARM].Dura * 10;
                                                    nTempDura -= M2Share.g_Config.nHPMPRockDecDura;
                                                    this.m_UseItems[Grobal2.U_CHARM].Dura = (ushort)HUtil32.Round((double)nTempDura / 10);
                                                    if (this.m_UseItems[Grobal2.U_CHARM].Dura > 0)
                                                    {
                                                        this.SendMsg(this, Grobal2.RM_DURACHANGE, Grobal2.U_CHARM, this.m_UseItems[Grobal2.U_CHARM].Dura, this.m_UseItems[Grobal2.U_CHARM].DuraMax, 0, "");
                                                    }
                                                    else
                                                    {
                                                        SendDelItems(this.m_UseItems[Grobal2.U_CHARM]);
                                                        this.m_UseItems[Grobal2.U_CHARM].wIndex = 0;
                                                    }
                                                }
                                                else
                                                {
                                                    this.m_WAbil.MP += M2Share.g_Config.nRockAddHPMP;
                                                    this.m_UseItems[Grobal2.U_CHARM].Dura = 0;
                                                    SendDelItems(this.m_UseItems[Grobal2.U_CHARM]);
                                                    this.m_UseItems[Grobal2.U_CHARM].wIndex = 0;
                                                }
                                                if (this.m_WAbil.MP > this.m_WAbil.MaxMP)
                                                {
                                                    this.m_WAbil.MP = this.m_WAbil.MaxMP;
                                                }
                                                this.PlugHealthSpellChanged();
                                            }
                                        }
                                        break;
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.PlaySuperRock");
            }
        }

        /// <summary>
        /// 清理包裹和仓库复制物品
        /// </summary>
        public void ClearCopyItem(byte nCode, int wIndex, int MakeIndex)
        {
            TUserItem UserItem;
            try
            {
                this.m_boOperationItemList = true;  // 防止同时操作背包列表时保存
                switch (nCode)
                {
                    case 0:// 检查背包中是否有复制品
                        for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                        {
                            if (this.m_ItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = this.m_ItemList[i];
                            if ((UserItem.wIndex == wIndex) && (UserItem.MakeIndex == MakeIndex))
                            {
                                SendDelItems(UserItem);
                                M2Share.MainOutMessage("[清理包裹复制品](" + this.m_sCharName + ")" + M2Share.UserEngine.GetStdItemName(UserItem.wIndex)
                                    + "(" + (UserItem.MakeIndex).ToString() + ")[" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString()
                                    + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString()
                                    + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString()
                                    + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "/#" + (UserItem.btValue[15]).ToString()
                                    + "/" + (UserItem.btValue[16]).ToString() + "/" + (UserItem.btValue[17]).ToString() + "/" + (UserItem.btValue[18]).ToString()
                                    + "/" + (UserItem.btValue[19]).ToString());
                                this.m_ItemList.RemoveAt(i);
                                break;// 只找到一件则退出，提高效率
                            }
                        }
                        break;
                    case 1:
                        for (int i = m_StorageItemList.Count - 1; i >= 0; i--)
                        {
                            if (m_StorageItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = m_StorageItemList[i];
                            if ((UserItem.wIndex == wIndex) && (UserItem.MakeIndex == MakeIndex))
                            {
                                M2Share.MainOutMessage("[清理仓库复制品](" + this.m_sCharName + ")" + M2Share.UserEngine.GetStdItemName(UserItem.wIndex) + "("
                                    + (UserItem.MakeIndex).ToString() + ")[" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/"
                                    + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/"
                                    + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/"
                                    + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "/#" + (UserItem.btValue[15]).ToString() + "/"
                                    + (UserItem.btValue[16]).ToString() + "/" + (UserItem.btValue[17]).ToString() + "/" + (UserItem.btValue[18]).ToString() + "/"
                                    + (UserItem.btValue[19]).ToString());
                                m_StorageItemList.RemoveAt(i);
                                break;  // 找到一件则退出，提高效率
                            }
                        }
                        break;
                }
                this.m_boOperationItemList = false;// 防止同时操作背包列表时保存
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClearCopyItem");
                this.m_boOperationItemList = false;// 防止同时操作背包列表时保存
            }
        }

        // 检查人物装备死亡物品是否爆
        public bool CheckItemBindDieNoDrop(TUserItem UserItem)
        {
            bool result = false;
            TItemBind ItemBind;
            HUtil32.EnterCriticalSection(M2Share.g_ItemBindDieNoDropName);
            try
            {
                if (M2Share.g_ItemBindDieNoDropName.Count > 0)
                {
                    for (int i = 0; i < M2Share.g_ItemBindDieNoDropName.Count; i++)
                    {
                        //ItemBind = M2Share.g_ItemBindDieNoDropName[i];
                        //if (ItemBind != null)
                        //{
                        //    if (ItemBind.nItemIdx == UserItem.wIndex)
                        //    {
                        //        if (((ItemBind.sBindName).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0))
                        //        {
                        //            result = true;
                        //        }
                        //        return result;
                        //    }
                        //}
                    }
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(M2Share.g_ItemBindDieNoDropName);
            }
            return result;
        }
    }
}